diff options
Diffstat (limited to 'fs/inode.c')
| -rw-r--r-- | fs/inode.c | 57 | 
1 files changed, 36 insertions, 21 deletions
diff --git a/fs/inode.c b/fs/inode.c index d8d04bd72b59..108138d4e909 100644 --- a/fs/inode.c +++ b/fs/inode.c  | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <linux/cdev.h> | 22 | #include <linux/cdev.h> | 
| 23 | #include <linux/bootmem.h> | 23 | #include <linux/bootmem.h> | 
| 24 | #include <linux/inotify.h> | 24 | #include <linux/inotify.h> | 
| 25 | #include <linux/mount.h> | ||
| 25 | 26 | ||
| 26 | /* | 27 | /* | 
| 27 | * This is needed for the following functions: | 28 | * This is needed for the following functions: | 
| @@ -192,7 +193,7 @@ void inode_init_once(struct inode *inode) | |||
| 192 | INIT_HLIST_NODE(&inode->i_hash); | 193 | INIT_HLIST_NODE(&inode->i_hash); | 
| 193 | INIT_LIST_HEAD(&inode->i_dentry); | 194 | INIT_LIST_HEAD(&inode->i_dentry); | 
| 194 | INIT_LIST_HEAD(&inode->i_devices); | 195 | INIT_LIST_HEAD(&inode->i_devices); | 
| 195 | sema_init(&inode->i_sem, 1); | 196 | mutex_init(&inode->i_mutex); | 
| 196 | init_rwsem(&inode->i_alloc_sem); | 197 | init_rwsem(&inode->i_alloc_sem); | 
| 197 | INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC); | 198 | INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC); | 
| 198 | rwlock_init(&inode->i_data.tree_lock); | 199 | rwlock_init(&inode->i_data.tree_lock); | 
| @@ -770,7 +771,7 @@ EXPORT_SYMBOL(igrab); | |||
| 770 | * | 771 | * | 
| 771 | * Note, @test is called with the inode_lock held, so can't sleep. | 772 | * Note, @test is called with the inode_lock held, so can't sleep. | 
| 772 | */ | 773 | */ | 
| 773 | static inline struct inode *ifind(struct super_block *sb, | 774 | static struct inode *ifind(struct super_block *sb, | 
| 774 | struct hlist_head *head, int (*test)(struct inode *, void *), | 775 | struct hlist_head *head, int (*test)(struct inode *, void *), | 
| 775 | void *data, const int wait) | 776 | void *data, const int wait) | 
| 776 | { | 777 | { | 
| @@ -804,7 +805,7 @@ static inline struct inode *ifind(struct super_block *sb, | |||
| 804 | * | 805 | * | 
| 805 | * Otherwise NULL is returned. | 806 | * Otherwise NULL is returned. | 
| 806 | */ | 807 | */ | 
| 807 | static inline struct inode *ifind_fast(struct super_block *sb, | 808 | static struct inode *ifind_fast(struct super_block *sb, | 
| 808 | struct hlist_head *head, unsigned long ino) | 809 | struct hlist_head *head, unsigned long ino) | 
| 809 | { | 810 | { | 
| 810 | struct inode *inode; | 811 | struct inode *inode; | 
| @@ -1176,22 +1177,33 @@ sector_t bmap(struct inode * inode, sector_t block) | |||
| 1176 | EXPORT_SYMBOL(bmap); | 1177 | EXPORT_SYMBOL(bmap); | 
| 1177 | 1178 | ||
| 1178 | /** | 1179 | /** | 
| 1179 | * update_atime - update the access time | 1180 | * touch_atime - update the access time | 
| 1181 | * @mnt: mount the inode is accessed on | ||
| 1180 | * @inode: inode accessed | 1182 | * @inode: inode accessed | 
| 1181 | * | 1183 | * | 
| 1182 | * Update the accessed time on an inode and mark it for writeback. | 1184 | * Update the accessed time on an inode and mark it for writeback. | 
| 1183 | * This function automatically handles read only file systems and media, | 1185 | * This function automatically handles read only file systems and media, | 
| 1184 | * as well as the "noatime" flag and inode specific "noatime" markers. | 1186 | * as well as the "noatime" flag and inode specific "noatime" markers. | 
| 1185 | */ | 1187 | */ | 
| 1186 | void update_atime(struct inode *inode) | 1188 | void touch_atime(struct vfsmount *mnt, struct dentry *dentry) | 
| 1187 | { | 1189 | { | 
| 1190 | struct inode *inode = dentry->d_inode; | ||
| 1188 | struct timespec now; | 1191 | struct timespec now; | 
| 1189 | 1192 | ||
| 1190 | if (IS_NOATIME(inode)) | 1193 | if (IS_RDONLY(inode)) | 
| 1191 | return; | 1194 | return; | 
| 1192 | if (IS_NODIRATIME(inode) && S_ISDIR(inode->i_mode)) | 1195 | |
| 1196 | if ((inode->i_flags & S_NOATIME) || | ||
| 1197 | (inode->i_sb->s_flags & MS_NOATIME) || | ||
| 1198 | ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))) | ||
| 1193 | return; | 1199 | return; | 
| 1194 | if (IS_RDONLY(inode)) | 1200 | |
| 1201 | /* | ||
| 1202 | * We may have a NULL vfsmount when coming from NFSD | ||
| 1203 | */ | ||
| 1204 | if (mnt && | ||
| 1205 | ((mnt->mnt_flags & MNT_NOATIME) || | ||
| 1206 | ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)))) | ||
| 1195 | return; | 1207 | return; | 
| 1196 | 1208 | ||
| 1197 | now = current_fs_time(inode->i_sb); | 1209 | now = current_fs_time(inode->i_sb); | 
| @@ -1201,19 +1213,23 @@ void update_atime(struct inode *inode) | |||
| 1201 | } | 1213 | } | 
| 1202 | } | 1214 | } | 
| 1203 | 1215 | ||
| 1204 | EXPORT_SYMBOL(update_atime); | 1216 | EXPORT_SYMBOL(touch_atime); | 
| 1205 | 1217 | ||
| 1206 | /** | 1218 | /** | 
| 1207 | * inode_update_time - update mtime and ctime time | 1219 | * file_update_time - update mtime and ctime time | 
| 1208 | * @inode: inode accessed | 1220 | * @file: file accessed | 
| 1209 | * @ctime_too: update ctime too | ||
| 1210 | * | 1221 | * | 
| 1211 | * Update the mtime time on an inode and mark it for writeback. | 1222 | * Update the mtime and ctime members of an inode and mark the inode | 
| 1212 | * When ctime_too is specified update the ctime too. | 1223 | * for writeback. Note that this function is meant exclusively for | 
| 1224 | * usage in the file write path of filesystems, and filesystems may | ||
| 1225 | * choose to explicitly ignore update via this function with the | ||
| 1226 | * S_NOCTIME inode flag, e.g. for network filesystem where these | ||
| 1227 | * timestamps are handled by the server. | ||
| 1213 | */ | 1228 | */ | 
| 1214 | 1229 | ||
| 1215 | void inode_update_time(struct inode *inode, int ctime_too) | 1230 | void file_update_time(struct file *file) | 
| 1216 | { | 1231 | { | 
| 1232 | struct inode *inode = file->f_dentry->d_inode; | ||
| 1217 | struct timespec now; | 1233 | struct timespec now; | 
| 1218 | int sync_it = 0; | 1234 | int sync_it = 0; | 
| 1219 | 1235 | ||
| @@ -1227,16 +1243,15 @@ void inode_update_time(struct inode *inode, int ctime_too) | |||
| 1227 | sync_it = 1; | 1243 | sync_it = 1; | 
| 1228 | inode->i_mtime = now; | 1244 | inode->i_mtime = now; | 
| 1229 | 1245 | ||
| 1230 | if (ctime_too) { | 1246 | if (!timespec_equal(&inode->i_ctime, &now)) | 
| 1231 | if (!timespec_equal(&inode->i_ctime, &now)) | 1247 | sync_it = 1; | 
| 1232 | sync_it = 1; | 1248 | inode->i_ctime = now; | 
| 1233 | inode->i_ctime = now; | 1249 | |
| 1234 | } | ||
| 1235 | if (sync_it) | 1250 | if (sync_it) | 
| 1236 | mark_inode_dirty_sync(inode); | 1251 | mark_inode_dirty_sync(inode); | 
| 1237 | } | 1252 | } | 
| 1238 | 1253 | ||
| 1239 | EXPORT_SYMBOL(inode_update_time); | 1254 | EXPORT_SYMBOL(file_update_time); | 
| 1240 | 1255 | ||
| 1241 | int inode_needs_sync(struct inode *inode) | 1256 | int inode_needs_sync(struct inode *inode) | 
| 1242 | { | 1257 | { | 
