From ea6aaa083c10c65ec63d692f81acf3171f9d2d44 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 29 Nov 2017 13:30:24 -0800 Subject: [PATCH] scoutfs: promote inode invalidation to function Hoist the per-inode invalidation up into a function because we're about to add invalidating dentries in parent directories. This should result in no functional change. Signed-off-by: Zach Brown --- kmod/src/lock.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/kmod/src/lock.c b/kmod/src/lock.c index 85c08a93..2ea01f3b 100644 --- a/kmod/src/lock.c +++ b/kmod/src/lock.c @@ -163,6 +163,20 @@ static int put_task_ref(struct scoutfs_lock *lock, struct task_ref *ref) return 1; } +static void invalidate_inode(struct super_block *sb, u64 ino) +{ + struct inode *inode; + + inode = scoutfs_ilookup(sb, ino); + if (!inode) + return; + + if (S_ISREG(inode->i_mode)) + truncate_inode_pages(inode->i_mapping, 0); + + iput(inode); +} + /* * Invalidate caches on this because another node wants a lock * with the a lock with the given mode and range. We always have to @@ -174,7 +188,6 @@ static int invalidate_caches(struct super_block *sb, int mode, { struct scoutfs_key_buf *start = lock->start; struct scoutfs_key_buf *end = lock->end; - struct inode *inode; u64 ino, last; int ret; @@ -191,12 +204,7 @@ static int invalidate_caches(struct super_block *sb, int mode, ino = le64_to_cpu(lock->lock_name.first); last = ino + SCOUTFS_LOCK_INODE_GROUP_NR - 1; while (ino <= last) { - inode = scoutfs_ilookup(lock->sb, ino); - if (inode && S_ISREG(inode->i_mode)) - truncate_inode_pages(inode->i_mapping, - 0); - - iput(inode); + invalidate_inode(sb, ino); ino++; } }