Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1347021

[PATCH v5 3/5] vfs: Remove unnecessary list_for_each_entry_safe() variants

From Waiman Long <Waiman.Long@hpe.com>
Newsgroups linux.kernel
Subject [PATCH v5 3/5] vfs: Remove unnecessary list_for_each_entry_safe() variants
Date 2016-03-01 22:10 +0100
Message-ID <r7ZIm-6hp-15@gated-at.bofh.it> (permalink)
References <r7ZIm-6hp-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Jan Kara <jack@suse.cz>

evict_inodes() and invalidate_inodes() use list_for_each_entry_safe()
to iterate sb->s_inodes list. However, since we use i_lru list entry for
our local temporary list of inodes to destroy, the inode is guaranteed
to stay in sb->s_inodes list while we hold sb->s_inode_list_lock. So
there is no real need for safe iteration variant and we can use
list_for_each_entry() just fine.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Waiman Long <Waiman.Long@hpe.com>
---
 fs/inode.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/inode.c b/fs/inode.c
index 69b8b52..c9cbea8 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -596,12 +596,12 @@ static void dispose_list(struct list_head *head)
  */
 void evict_inodes(struct super_block *sb)
 {
-	struct inode *inode, *next;
+	struct inode *inode;
 	LIST_HEAD(dispose);
 
 again:
 	spin_lock(&sb->s_inode_list_lock);
-	list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
+	list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
 		if (atomic_read(&inode->i_count))
 			continue;
 
@@ -646,11 +646,11 @@ again:
 int invalidate_inodes(struct super_block *sb, bool kill_dirty)
 {
 	int busy = 0;
-	struct inode *inode, *next;
+	struct inode *inode;
 	LIST_HEAD(dispose);
 
 	spin_lock(&sb->s_inode_list_lock);
-	list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
+	list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
 		spin_lock(&inode->i_lock);
 		if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
 			spin_unlock(&inode->i_lock);
-- 
1.7.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 0/5] vfs: Use per-cpu list for SB's s_inodes list Waiman Long <Waiman.Long@hpe.com> - 2016-03-01 22:10 +0100
  [PATCH v5 3/5] vfs: Remove unnecessary list_for_each_entry_safe() variants Waiman Long <Waiman.Long@hpe.com> - 2016-03-01 22:10 +0100
  [PATCH v5 4/5] vfs: Use per-cpu list for superblock's inode list Waiman Long <Waiman.Long@hpe.com> - 2016-03-01 22:10 +0100
  [PATCH v5 1/5] lib/percpu-list: Per-cpu list with associated per-cpu locks Waiman Long <Waiman.Long@hpe.com> - 2016-03-01 22:10 +0100
  [PATCH v5 5/5] lib/percpu-list: Add a config parameter for disabling per-cpu list Waiman Long <Waiman.Long@hpe.com> - 2016-03-01 22:10 +0100
    Re: [PATCH v5 5/5] lib/percpu-list: Add a config parameter for  disabling per-cpu list Ingo Molnar <mingo@kernel.org> - 2016-03-02 09:50 +0100
      Re: [PATCH v5 5/5] lib/percpu-list: Add a config parameter for disabling  per-cpu list Waiman Long <waiman.long@hpe.com> - 2016-03-02 23:00 +0100
  Re: [PATCH v5 0/5] vfs: Use per-cpu list for SB's s_inodes list Jan Kara <jack@suse.cz> - 2016-03-03 11:50 +0100

csiph-web