···827827}828828829829/*830830+ * The ffd.file pointer may be in the process of being torn down due to831831+ * being closed, but we may not have finished eventpoll_release() yet.832832+ *833833+ * Normally, even with the atomic_long_inc_not_zero, the file may have834834+ * been free'd and then gotten re-allocated to something else (since835835+ * files are not RCU-delayed, they are SLAB_TYPESAFE_BY_RCU).836836+ *837837+ * But for epoll, users hold the ep->mtx mutex, and as such any file in838838+ * the process of being free'd will block in eventpoll_release_file()839839+ * and thus the underlying file allocation will not be free'd, and the840840+ * file re-use cannot happen.841841+ *842842+ * For the same reason we can avoid a rcu_read_lock() around the843843+ * operation - 'ffd.file' cannot go away even if the refcount has844844+ * reached zero (but we must still not call out to ->poll() functions845845+ * etc).846846+ */847847+static struct file *epi_fget(const struct epitem *epi)848848+{849849+ struct file *file;850850+851851+ file = epi->ffd.file;852852+ if (!file_ref_get(&file->f_ref))853853+ file = NULL;854854+ return file;855855+}856856+857857+/*830858 * Called with &file->f_lock held,831859 * returns with it released832860 */···10441016 ep_done_scan(ep, &txlist);10451017 mutex_unlock(&ep->mtx);10461018 return res;10471047-}10481048-10491049-/*10501050- * The ffd.file pointer may be in the process of being torn down due to10511051- * being closed, but we may not have finished eventpoll_release() yet.10521052- *10531053- * Normally, even with the atomic_long_inc_not_zero, the file may have10541054- * been free'd and then gotten re-allocated to something else (since10551055- * files are not RCU-delayed, they are SLAB_TYPESAFE_BY_RCU).10561056- *10571057- * But for epoll, users hold the ep->mtx mutex, and as such any file in10581058- * the process of being free'd will block in eventpoll_release_file()10591059- * and thus the underlying file allocation will not be free'd, and the10601060- * file re-use cannot happen.10611061- *10621062- * For the same reason we can avoid a rcu_read_lock() around the10631063- * operation - 'ffd.file' cannot go away even if the refcount has10641064- * reached zero (but we must still not call out to ->poll() functions10651065- * etc).10661066- */10671067-static struct file *epi_fget(const struct epitem *epi)10681068-{10691069- struct file *file;10701070-10711071- file = epi->ffd.file;10721072- if (!file_ref_get(&file->f_ref))10731073- file = NULL;10741074- return file;10751019}1076102010771021/*