···12441244CONFIG_DEBUG_HIGHMEM=y12451245CONFIG_DEBUG_INFO=y12461246CONFIG_DEBUG_VM=y12471247-CONFIG_DEBUG_WRITECOUNT=y12481247CONFIG_DEBUG_LIST=y12491248CONFIG_DEBUG_SG=y12501249# CONFIG_RCU_CPU_STALL_DETECTOR is not set
···627627# CONFIG_DEBUG_KOBJECT is not set628628# CONFIG_DEBUG_INFO is not set629629# CONFIG_DEBUG_VM is not set630630-# CONFIG_DEBUG_WRITECOUNT is not set631630# CONFIG_DEBUG_MEMORY_INIT is not set632631# CONFIG_DEBUG_LIST is not set633632# CONFIG_DEBUG_SG is not set
-1
arch/xtensa/configs/s6105_defconfig
···569569# CONFIG_DEBUG_INFO is not set570570# CONFIG_DEBUG_VM is not set571571CONFIG_DEBUG_NOMMU_REGIONS=y572572-# CONFIG_DEBUG_WRITECOUNT is not set573572# CONFIG_DEBUG_MEMORY_INIT is not set574573# CONFIG_DEBUG_LIST is not set575574# CONFIG_DEBUG_SG is not set
-5
fs/file_table.c
···5252static inline void file_free(struct file *f)5353{5454 percpu_counter_dec(&nr_files);5555- file_check_state(f);5655 call_rcu(&f->f_u.fu_rcuhead, file_free_rcu);5756}5857···185186 * that we can do debugging checks at __fput()186187 */187188 if ((mode & FMODE_WRITE) && !special_file(path->dentry->d_inode->i_mode)) {188188- file_take_write(file);189189 WARN_ON(mnt_clone_write(path->mnt));190190 }191191 if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)···211213 return;212214213215 put_write_access(inode);214214- if (file_check_writeable(file) != 0)215215- return;216216 __mnt_drop_write(mnt);217217- file_release_write(file);218217}219218220219/* the real guts of fput() - releasing the last reference to file
-8
fs/open.c
···683683 error = __get_file_write_access(inode, f->f_path.mnt);684684 if (error)685685 goto cleanup_file;686686- file_take_write(f);687686 }688687689688 f->f_mapping = inode->i_mapping;···730731 fops_put(f->f_op);731732 if (f->f_mode & FMODE_WRITE) {732733 if (!special_file(inode->i_mode)) {733733- /*734734- * We don't consider this a real735735- * mnt_want/drop_write() pair736736- * because it all happenend right737737- * here, so just reset the state.738738- */739734 put_write_access(inode);740740- file_reset_write(f);741735 __mnt_drop_write(f->f_path.mnt);742736 }743737 }
-49
include/linux/fs.h
···769769 index < ra->start + ra->size);770770}771771772772-#define FILE_MNT_WRITE_TAKEN 1773773-#define FILE_MNT_WRITE_RELEASED 2774774-775772struct file {776773 union {777774 struct llist_node fu_llist;···806809 struct list_head f_tfile_llink;807810#endif /* #ifdef CONFIG_EPOLL */808811 struct address_space *f_mapping;809809-#ifdef CONFIG_DEBUG_WRITECOUNT810810- unsigned long f_mnt_write_state;811811-#endif812812} __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */813813814814struct file_handle {···822828}823829#define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1)824830#define file_count(x) atomic_long_read(&(x)->f_count)825825-826826-#ifdef CONFIG_DEBUG_WRITECOUNT827827-static inline void file_take_write(struct file *f)828828-{829829- WARN_ON(f->f_mnt_write_state != 0);830830- f->f_mnt_write_state = FILE_MNT_WRITE_TAKEN;831831-}832832-static inline void file_release_write(struct file *f)833833-{834834- f->f_mnt_write_state |= FILE_MNT_WRITE_RELEASED;835835-}836836-static inline void file_reset_write(struct file *f)837837-{838838- f->f_mnt_write_state = 0;839839-}840840-static inline void file_check_state(struct file *f)841841-{842842- /*843843- * At this point, either both or neither of these bits844844- * should be set.845845- */846846- WARN_ON(f->f_mnt_write_state == FILE_MNT_WRITE_TAKEN);847847- WARN_ON(f->f_mnt_write_state == FILE_MNT_WRITE_RELEASED);848848-}849849-static inline int file_check_writeable(struct file *f)850850-{851851- if (f->f_mnt_write_state == FILE_MNT_WRITE_TAKEN)852852- return 0;853853- printk(KERN_WARNING "writeable file with no "854854- "mnt_want_write()\n");855855- WARN_ON(1);856856- return -EINVAL;857857-}858858-#else /* !CONFIG_DEBUG_WRITECOUNT */859859-static inline void file_take_write(struct file *filp) {}860860-static inline void file_release_write(struct file *filp) {}861861-static inline void file_reset_write(struct file *filp) {}862862-static inline void file_check_state(struct file *filp) {}863863-static inline int file_check_writeable(struct file *filp)864864-{865865- return 0;866866-}867867-#endif /* CONFIG_DEBUG_WRITECOUNT */868831869832#define MAX_NON_LFS ((1UL<<31) - 1)870833
-10
lib/Kconfig.debug
···10301030 of the BUG call as well as the EIP and oops trace. This aids10311031 debugging but costs about 70-100K of memory.1032103210331033-config DEBUG_WRITECOUNT10341034- bool "Debug filesystem writers count"10351035- depends on DEBUG_KERNEL10361036- help10371037- Enable this to catch wrong use of the writers count in struct10381038- vfsmount. This will increase the size of each file struct by10391039- 32 bits.10401040-10411041- If unsure, say N.10421042-10431033config DEBUG_LIST10441034 bool "Debug linked list manipulation"10451035 depends on DEBUG_KERNEL