Commit a031878670ac8fe466859d4c1506bd91ae48678c

Authored by Christoph Hellwig
Committed by Al Viro
1 parent d895a1c96a

fs: fold invalidate_list into invalidate_inodes

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 1 changed file with 16 additions and 27 deletions Side-by-side Diff

... ... @@ -477,15 +477,24 @@
477 477 }
478 478 }
479 479  
480   -/*
481   - * Invalidate all inodes for a device.
  480 +/**
  481 + * invalidate_inodes - attempt to free all inodes on a superblock
  482 + * @sb: superblock to operate on
  483 + *
  484 + * Attempts to free all inodes for a given superblock. If there were any
  485 + * busy inodes return a non-zero value, else zero.
482 486 */
483   -static int invalidate_list(struct list_head *head, struct list_head *dispose)
  487 +int invalidate_inodes(struct super_block *sb)
484 488 {
485   - struct inode *inode, *next;
486 489 int busy = 0;
  490 + struct inode *inode, *next;
  491 + LIST_HEAD(dispose);
487 492  
488   - list_for_each_entry_safe(inode, next, head, i_sb_list) {
  493 + down_write(&iprune_sem);
  494 +
  495 + spin_lock(&inode_lock);
  496 + fsnotify_unmount_inodes(&sb->s_inodes);
  497 + list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
489 498 if (inode->i_state & I_NEW)
490 499 continue;
491 500 if (atomic_read(&inode->i_count)) {
492 501  
493 502  
... ... @@ -499,34 +508,14 @@
499 508 * Move the inode off the IO lists and LRU once I_FREEING is
500 509 * set so that it won't get moved back on there if it is dirty.
501 510 */
502   - list_move(&inode->i_lru, dispose);
  511 + list_move(&inode->i_lru, &dispose);
503 512 list_del_init(&inode->i_wb_list);
504 513 if (!(inode->i_state & (I_DIRTY | I_SYNC)))
505 514 percpu_counter_dec(&nr_inodes_unused);
506 515 }
507   - return busy;
508   -}
509   -
510   -/**
511   - * invalidate_inodes - discard the inodes on a device
512   - * @sb: superblock
513   - *
514   - * Discard all of the inodes for a given superblock. If the discard
515   - * fails because there are busy inodes then a non zero value is returned.
516   - * If the discard is successful all the inodes have been discarded.
517   - */
518   -int invalidate_inodes(struct super_block *sb)
519   -{
520   - int busy;
521   - LIST_HEAD(throw_away);
522   -
523   - down_write(&iprune_sem);
524   - spin_lock(&inode_lock);
525   - fsnotify_unmount_inodes(&sb->s_inodes);
526   - busy = invalidate_list(&sb->s_inodes, &throw_away);
527 516 spin_unlock(&inode_lock);
528 517  
529   - dispose_list(&throw_away);
  518 + dispose_list(&dispose);
530 519 up_write(&iprune_sem);
531 520  
532 521 return busy;