diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-10-23 01:01:49 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-10-23 01:01:49 -0400 |
commit | 3dd41424090a0ca3a660218d06afe6ff4441bad3 (patch) | |
tree | 511ef1bb1799027fc5aad574adce49120ecadd87 /fs/inode.c | |
parent | 5c5456402d467969b217d7fdd6670f8c8600f5a8 (diff) | |
parent | f6f94e2ab1b33f0082ac22d71f66385a60d8157f (diff) |
Merge commit 'v2.6.36' into wip-merge-2.6.36
Conflicts:
Makefile
arch/x86/include/asm/unistd_32.h
arch/x86/kernel/syscall_table_32.S
kernel/sched.c
kernel/time/tick-sched.c
Relevant API and functions changes (solved in this commit):
- (API) .enqueue_task() (enqueue_task_litmus),
dequeue_task() (dequeue_task_litmus),
[litmus/sched_litmus.c]
- (API) .select_task_rq() (select_task_rq_litmus)
[litmus/sched_litmus.c]
- (API) sysrq_dump_trace_buffer() and sysrq_handle_kill_rt_tasks()
[litmus/sched_trace.c]
- struct kfifo internal buffer name changed (buffer -> buf)
[litmus/sched_trace.c]
- add_wait_queue_exclusive_locked -> __add_wait_queue_tail_exclusive
[litmus/fmlp.c]
- syscall numbers for both x86_32 and x86_64
Diffstat (limited to 'fs/inode.c')
-rw-r--r-- | fs/inode.c | 215 |
1 files changed, 83 insertions, 132 deletions
diff --git a/fs/inode.c b/fs/inode.c index aaaaf096aa8e..d4fe9c031864 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/pagemap.h> | 20 | #include <linux/pagemap.h> |
21 | #include <linux/cdev.h> | 21 | #include <linux/cdev.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/bootmem.h> |
23 | #include <linux/inotify.h> | ||
24 | #include <linux/fsnotify.h> | 23 | #include <linux/fsnotify.h> |
25 | #include <linux/mount.h> | 24 | #include <linux/mount.h> |
26 | #include <linux/async.h> | 25 | #include <linux/async.h> |
@@ -264,12 +263,8 @@ void inode_init_once(struct inode *inode) | |||
264 | INIT_RAW_PRIO_TREE_ROOT(&inode->i_data.i_mmap); | 263 | INIT_RAW_PRIO_TREE_ROOT(&inode->i_data.i_mmap); |
265 | INIT_LIST_HEAD(&inode->i_data.i_mmap_nonlinear); | 264 | INIT_LIST_HEAD(&inode->i_data.i_mmap_nonlinear); |
266 | i_size_ordered_init(inode); | 265 | i_size_ordered_init(inode); |
267 | #ifdef CONFIG_INOTIFY | ||
268 | INIT_LIST_HEAD(&inode->inotify_watches); | ||
269 | mutex_init(&inode->inotify_mutex); | ||
270 | #endif | ||
271 | #ifdef CONFIG_FSNOTIFY | 266 | #ifdef CONFIG_FSNOTIFY |
272 | INIT_HLIST_HEAD(&inode->i_fsnotify_mark_entries); | 267 | INIT_HLIST_HEAD(&inode->i_fsnotify_marks); |
273 | #endif | 268 | #endif |
274 | INIT_LIST_HEAD(&inode->i_obj_list); | 269 | INIT_LIST_HEAD(&inode->i_obj_list); |
275 | mutex_init(&inode->i_obj_mutex); | 270 | mutex_init(&inode->i_obj_mutex); |
@@ -288,42 +283,42 @@ static void init_once(void *foo) | |||
288 | */ | 283 | */ |
289 | void __iget(struct inode *inode) | 284 | void __iget(struct inode *inode) |
290 | { | 285 | { |
291 | if (atomic_read(&inode->i_count)) { | 286 | if (atomic_inc_return(&inode->i_count) != 1) |
292 | atomic_inc(&inode->i_count); | ||
293 | return; | 287 | return; |
294 | } | 288 | |
295 | atomic_inc(&inode->i_count); | ||
296 | if (!(inode->i_state & (I_DIRTY|I_SYNC))) | 289 | if (!(inode->i_state & (I_DIRTY|I_SYNC))) |
297 | list_move(&inode->i_list, &inode_in_use); | 290 | list_move(&inode->i_list, &inode_in_use); |
298 | inodes_stat.nr_unused--; | 291 | inodes_stat.nr_unused--; |
299 | } | 292 | } |
300 | 293 | ||
301 | /** | 294 | void end_writeback(struct inode *inode) |
302 | * clear_inode - clear an inode | ||
303 | * @inode: inode to clear | ||
304 | * | ||
305 | * This is called by the filesystem to tell us | ||
306 | * that the inode is no longer useful. We just | ||
307 | * terminate it with extreme prejudice. | ||
308 | */ | ||
309 | void clear_inode(struct inode *inode) | ||
310 | { | 295 | { |
311 | might_sleep(); | 296 | might_sleep(); |
312 | invalidate_inode_buffers(inode); | ||
313 | |||
314 | BUG_ON(inode->i_data.nrpages); | 297 | BUG_ON(inode->i_data.nrpages); |
298 | BUG_ON(!list_empty(&inode->i_data.private_list)); | ||
315 | BUG_ON(!(inode->i_state & I_FREEING)); | 299 | BUG_ON(!(inode->i_state & I_FREEING)); |
316 | BUG_ON(inode->i_state & I_CLEAR); | 300 | BUG_ON(inode->i_state & I_CLEAR); |
317 | inode_sync_wait(inode); | 301 | inode_sync_wait(inode); |
318 | if (inode->i_sb->s_op->clear_inode) | 302 | inode->i_state = I_FREEING | I_CLEAR; |
319 | inode->i_sb->s_op->clear_inode(inode); | 303 | } |
304 | EXPORT_SYMBOL(end_writeback); | ||
305 | |||
306 | static void evict(struct inode *inode) | ||
307 | { | ||
308 | const struct super_operations *op = inode->i_sb->s_op; | ||
309 | |||
310 | if (op->evict_inode) { | ||
311 | op->evict_inode(inode); | ||
312 | } else { | ||
313 | if (inode->i_data.nrpages) | ||
314 | truncate_inode_pages(&inode->i_data, 0); | ||
315 | end_writeback(inode); | ||
316 | } | ||
320 | if (S_ISBLK(inode->i_mode) && inode->i_bdev) | 317 | if (S_ISBLK(inode->i_mode) && inode->i_bdev) |
321 | bd_forget(inode); | 318 | bd_forget(inode); |
322 | if (S_ISCHR(inode->i_mode) && inode->i_cdev) | 319 | if (S_ISCHR(inode->i_mode) && inode->i_cdev) |
323 | cd_forget(inode); | 320 | cd_forget(inode); |
324 | inode->i_state = I_CLEAR; | ||
325 | } | 321 | } |
326 | EXPORT_SYMBOL(clear_inode); | ||
327 | 322 | ||
328 | /* | 323 | /* |
329 | * dispose_list - dispose of the contents of a local list | 324 | * dispose_list - dispose of the contents of a local list |
@@ -342,9 +337,7 @@ static void dispose_list(struct list_head *head) | |||
342 | inode = list_first_entry(head, struct inode, i_list); | 337 | inode = list_first_entry(head, struct inode, i_list); |
343 | list_del(&inode->i_list); | 338 | list_del(&inode->i_list); |
344 | 339 | ||
345 | if (inode->i_data.nrpages) | 340 | evict(inode); |
346 | truncate_inode_pages(&inode->i_data, 0); | ||
347 | clear_inode(inode); | ||
348 | 341 | ||
349 | spin_lock(&inode_lock); | 342 | spin_lock(&inode_lock); |
350 | hlist_del_init(&inode->i_hash); | 343 | hlist_del_init(&inode->i_hash); |
@@ -417,7 +410,6 @@ int invalidate_inodes(struct super_block *sb) | |||
417 | 410 | ||
418 | down_write(&iprune_sem); | 411 | down_write(&iprune_sem); |
419 | spin_lock(&inode_lock); | 412 | spin_lock(&inode_lock); |
420 | inotify_unmount_inodes(&sb->s_inodes); | ||
421 | fsnotify_unmount_inodes(&sb->s_inodes); | 413 | fsnotify_unmount_inodes(&sb->s_inodes); |
422 | busy = invalidate_list(&sb->s_inodes, &throw_away); | 414 | busy = invalidate_list(&sb->s_inodes, &throw_away); |
423 | spin_unlock(&inode_lock); | 415 | spin_unlock(&inode_lock); |
@@ -516,7 +508,7 @@ static void prune_icache(int nr_to_scan) | |||
516 | * This function is passed the number of inodes to scan, and it returns the | 508 | * This function is passed the number of inodes to scan, and it returns the |
517 | * total number of remaining possibly-reclaimable inodes. | 509 | * total number of remaining possibly-reclaimable inodes. |
518 | */ | 510 | */ |
519 | static int shrink_icache_memory(int nr, gfp_t gfp_mask) | 511 | static int shrink_icache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask) |
520 | { | 512 | { |
521 | if (nr) { | 513 | if (nr) { |
522 | /* | 514 | /* |
@@ -557,7 +549,7 @@ repeat: | |||
557 | continue; | 549 | continue; |
558 | if (!test(inode, data)) | 550 | if (!test(inode, data)) |
559 | continue; | 551 | continue; |
560 | if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) { | 552 | if (inode->i_state & (I_FREEING|I_WILL_FREE)) { |
561 | __wait_on_freeing_inode(inode); | 553 | __wait_on_freeing_inode(inode); |
562 | goto repeat; | 554 | goto repeat; |
563 | } | 555 | } |
@@ -582,7 +574,7 @@ repeat: | |||
582 | continue; | 574 | continue; |
583 | if (inode->i_sb != sb) | 575 | if (inode->i_sb != sb) |
584 | continue; | 576 | continue; |
585 | if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) { | 577 | if (inode->i_state & (I_FREEING|I_WILL_FREE)) { |
586 | __wait_on_freeing_inode(inode); | 578 | __wait_on_freeing_inode(inode); |
587 | goto repeat; | 579 | goto repeat; |
588 | } | 580 | } |
@@ -844,7 +836,7 @@ EXPORT_SYMBOL(iunique); | |||
844 | struct inode *igrab(struct inode *inode) | 836 | struct inode *igrab(struct inode *inode) |
845 | { | 837 | { |
846 | spin_lock(&inode_lock); | 838 | spin_lock(&inode_lock); |
847 | if (!(inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE))) | 839 | if (!(inode->i_state & (I_FREEING|I_WILL_FREE))) |
848 | __iget(inode); | 840 | __iget(inode); |
849 | else | 841 | else |
850 | /* | 842 | /* |
@@ -1093,7 +1085,7 @@ int insert_inode_locked(struct inode *inode) | |||
1093 | continue; | 1085 | continue; |
1094 | if (old->i_sb != sb) | 1086 | if (old->i_sb != sb) |
1095 | continue; | 1087 | continue; |
1096 | if (old->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) | 1088 | if (old->i_state & (I_FREEING|I_WILL_FREE)) |
1097 | continue; | 1089 | continue; |
1098 | break; | 1090 | break; |
1099 | } | 1091 | } |
@@ -1132,7 +1124,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval, | |||
1132 | continue; | 1124 | continue; |
1133 | if (!test(old, data)) | 1125 | if (!test(old, data)) |
1134 | continue; | 1126 | continue; |
1135 | if (old->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) | 1127 | if (old->i_state & (I_FREEING|I_WILL_FREE)) |
1136 | continue; | 1128 | continue; |
1137 | break; | 1129 | break; |
1138 | } | 1130 | } |
@@ -1184,71 +1176,51 @@ void remove_inode_hash(struct inode *inode) | |||
1184 | } | 1176 | } |
1185 | EXPORT_SYMBOL(remove_inode_hash); | 1177 | EXPORT_SYMBOL(remove_inode_hash); |
1186 | 1178 | ||
1179 | int generic_delete_inode(struct inode *inode) | ||
1180 | { | ||
1181 | return 1; | ||
1182 | } | ||
1183 | EXPORT_SYMBOL(generic_delete_inode); | ||
1184 | |||
1187 | /* | 1185 | /* |
1188 | * Tell the filesystem that this inode is no longer of any interest and should | 1186 | * Normal UNIX filesystem behaviour: delete the |
1189 | * be completely destroyed. | 1187 | * inode when the usage count drops to zero, and |
1190 | * | 1188 | * i_nlink is zero. |
1191 | * We leave the inode in the inode hash table until *after* the filesystem's | ||
1192 | * ->delete_inode completes. This ensures that an iget (such as nfsd might | ||
1193 | * instigate) will always find up-to-date information either in the hash or on | ||
1194 | * disk. | ||
1195 | * | ||
1196 | * I_FREEING is set so that no-one will take a new reference to the inode while | ||
1197 | * it is being deleted. | ||
1198 | */ | 1189 | */ |
1199 | void generic_delete_inode(struct inode *inode) | 1190 | int generic_drop_inode(struct inode *inode) |
1200 | { | 1191 | { |
1201 | const struct super_operations *op = inode->i_sb->s_op; | 1192 | return !inode->i_nlink || hlist_unhashed(&inode->i_hash); |
1202 | |||
1203 | list_del_init(&inode->i_list); | ||
1204 | list_del_init(&inode->i_sb_list); | ||
1205 | WARN_ON(inode->i_state & I_NEW); | ||
1206 | inode->i_state |= I_FREEING; | ||
1207 | inodes_stat.nr_inodes--; | ||
1208 | spin_unlock(&inode_lock); | ||
1209 | |||
1210 | security_inode_delete(inode); | ||
1211 | |||
1212 | if (op->delete_inode) { | ||
1213 | void (*delete)(struct inode *) = op->delete_inode; | ||
1214 | /* Filesystems implementing their own | ||
1215 | * s_op->delete_inode are required to call | ||
1216 | * truncate_inode_pages and clear_inode() | ||
1217 | * internally */ | ||
1218 | delete(inode); | ||
1219 | } else { | ||
1220 | truncate_inode_pages(&inode->i_data, 0); | ||
1221 | clear_inode(inode); | ||
1222 | } | ||
1223 | spin_lock(&inode_lock); | ||
1224 | hlist_del_init(&inode->i_hash); | ||
1225 | spin_unlock(&inode_lock); | ||
1226 | wake_up_inode(inode); | ||
1227 | BUG_ON(inode->i_state != I_CLEAR); | ||
1228 | destroy_inode(inode); | ||
1229 | } | 1193 | } |
1230 | EXPORT_SYMBOL(generic_delete_inode); | 1194 | EXPORT_SYMBOL_GPL(generic_drop_inode); |
1231 | 1195 | ||
1232 | /** | 1196 | /* |
1233 | * generic_detach_inode - remove inode from inode lists | 1197 | * Called when we're dropping the last reference |
1234 | * @inode: inode to remove | 1198 | * to an inode. |
1235 | * | ||
1236 | * Remove inode from inode lists, write it if it's dirty. This is just an | ||
1237 | * internal VFS helper exported for hugetlbfs. Do not use! | ||
1238 | * | 1199 | * |
1239 | * Returns 1 if inode should be completely destroyed. | 1200 | * Call the FS "drop_inode()" function, defaulting to |
1201 | * the legacy UNIX filesystem behaviour. If it tells | ||
1202 | * us to evict inode, do so. Otherwise, retain inode | ||
1203 | * in cache if fs is alive, sync and evict if fs is | ||
1204 | * shutting down. | ||
1240 | */ | 1205 | */ |
1241 | int generic_detach_inode(struct inode *inode) | 1206 | static void iput_final(struct inode *inode) |
1242 | { | 1207 | { |
1243 | struct super_block *sb = inode->i_sb; | 1208 | struct super_block *sb = inode->i_sb; |
1209 | const struct super_operations *op = inode->i_sb->s_op; | ||
1210 | int drop; | ||
1244 | 1211 | ||
1245 | if (!hlist_unhashed(&inode->i_hash)) { | 1212 | if (op && op->drop_inode) |
1213 | drop = op->drop_inode(inode); | ||
1214 | else | ||
1215 | drop = generic_drop_inode(inode); | ||
1216 | |||
1217 | if (!drop) { | ||
1246 | if (!(inode->i_state & (I_DIRTY|I_SYNC))) | 1218 | if (!(inode->i_state & (I_DIRTY|I_SYNC))) |
1247 | list_move(&inode->i_list, &inode_unused); | 1219 | list_move(&inode->i_list, &inode_unused); |
1248 | inodes_stat.nr_unused++; | 1220 | inodes_stat.nr_unused++; |
1249 | if (sb->s_flags & MS_ACTIVE) { | 1221 | if (sb->s_flags & MS_ACTIVE) { |
1250 | spin_unlock(&inode_lock); | 1222 | spin_unlock(&inode_lock); |
1251 | return 0; | 1223 | return; |
1252 | } | 1224 | } |
1253 | WARN_ON(inode->i_state & I_NEW); | 1225 | WARN_ON(inode->i_state & I_NEW); |
1254 | inode->i_state |= I_WILL_FREE; | 1226 | inode->i_state |= I_WILL_FREE; |
@@ -1266,56 +1238,15 @@ int generic_detach_inode(struct inode *inode) | |||
1266 | inode->i_state |= I_FREEING; | 1238 | inode->i_state |= I_FREEING; |
1267 | inodes_stat.nr_inodes--; | 1239 | inodes_stat.nr_inodes--; |
1268 | spin_unlock(&inode_lock); | 1240 | spin_unlock(&inode_lock); |
1269 | return 1; | 1241 | evict(inode); |
1270 | } | 1242 | spin_lock(&inode_lock); |
1271 | EXPORT_SYMBOL_GPL(generic_detach_inode); | 1243 | hlist_del_init(&inode->i_hash); |
1272 | 1244 | spin_unlock(&inode_lock); | |
1273 | static void generic_forget_inode(struct inode *inode) | ||
1274 | { | ||
1275 | if (!generic_detach_inode(inode)) | ||
1276 | return; | ||
1277 | if (inode->i_data.nrpages) | ||
1278 | truncate_inode_pages(&inode->i_data, 0); | ||
1279 | clear_inode(inode); | ||
1280 | wake_up_inode(inode); | 1245 | wake_up_inode(inode); |
1246 | BUG_ON(inode->i_state != (I_FREEING | I_CLEAR)); | ||
1281 | destroy_inode(inode); | 1247 | destroy_inode(inode); |
1282 | } | 1248 | } |
1283 | 1249 | ||
1284 | /* | ||
1285 | * Normal UNIX filesystem behaviour: delete the | ||
1286 | * inode when the usage count drops to zero, and | ||
1287 | * i_nlink is zero. | ||
1288 | */ | ||
1289 | void generic_drop_inode(struct inode *inode) | ||
1290 | { | ||
1291 | if (!inode->i_nlink) | ||
1292 | generic_delete_inode(inode); | ||
1293 | else | ||
1294 | generic_forget_inode(inode); | ||
1295 | } | ||
1296 | EXPORT_SYMBOL_GPL(generic_drop_inode); | ||
1297 | |||
1298 | /* | ||
1299 | * Called when we're dropping the last reference | ||
1300 | * to an inode. | ||
1301 | * | ||
1302 | * Call the FS "drop()" function, defaulting to | ||
1303 | * the legacy UNIX filesystem behaviour.. | ||
1304 | * | ||
1305 | * NOTE! NOTE! NOTE! We're called with the inode lock | ||
1306 | * held, and the drop function is supposed to release | ||
1307 | * the lock! | ||
1308 | */ | ||
1309 | static inline void iput_final(struct inode *inode) | ||
1310 | { | ||
1311 | const struct super_operations *op = inode->i_sb->s_op; | ||
1312 | void (*drop)(struct inode *) = generic_drop_inode; | ||
1313 | |||
1314 | if (op && op->drop_inode) | ||
1315 | drop = op->drop_inode; | ||
1316 | drop(inode); | ||
1317 | } | ||
1318 | |||
1319 | /** | 1250 | /** |
1320 | * iput - put an inode | 1251 | * iput - put an inode |
1321 | * @inode: inode to put | 1252 | * @inode: inode to put |
@@ -1328,7 +1259,7 @@ static inline void iput_final(struct inode *inode) | |||
1328 | void iput(struct inode *inode) | 1259 | void iput(struct inode *inode) |
1329 | { | 1260 | { |
1330 | if (inode) { | 1261 | if (inode) { |
1331 | BUG_ON(inode->i_state == I_CLEAR); | 1262 | BUG_ON(inode->i_state & I_CLEAR); |
1332 | 1263 | ||
1333 | if (atomic_dec_and_lock(&inode->i_count, &inode_lock)) | 1264 | if (atomic_dec_and_lock(&inode->i_count, &inode_lock)) |
1334 | iput_final(inode); | 1265 | iput_final(inode); |
@@ -1612,3 +1543,23 @@ void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev) | |||
1612 | inode->i_ino); | 1543 | inode->i_ino); |
1613 | } | 1544 | } |
1614 | EXPORT_SYMBOL(init_special_inode); | 1545 | EXPORT_SYMBOL(init_special_inode); |
1546 | |||
1547 | /** | ||
1548 | * Init uid,gid,mode for new inode according to posix standards | ||
1549 | * @inode: New inode | ||
1550 | * @dir: Directory inode | ||
1551 | * @mode: mode of the new inode | ||
1552 | */ | ||
1553 | void inode_init_owner(struct inode *inode, const struct inode *dir, | ||
1554 | mode_t mode) | ||
1555 | { | ||
1556 | inode->i_uid = current_fsuid(); | ||
1557 | if (dir && dir->i_mode & S_ISGID) { | ||
1558 | inode->i_gid = dir->i_gid; | ||
1559 | if (S_ISDIR(mode)) | ||
1560 | mode |= S_ISGID; | ||
1561 | } else | ||
1562 | inode->i_gid = current_fsgid(); | ||
1563 | inode->i_mode = mode; | ||
1564 | } | ||
1565 | EXPORT_SYMBOL(inode_init_owner); | ||