Skip to content

Commit df91b9d

Browse files
oleg-nesterovdhowells
authored andcommitted
afs: use read_seqbegin() in afs_check_validity() and afs_getattr()
David Howells says: (3) afs_check_validity(). (4) afs_getattr(). These are both pretty short, so your solution is probably good for them. That said, afs_vnode_commit_status() can spend a long time under the write lock - and pretty much every file RPC op returns a status update. Change these functions to use read_seqbegin(). This simplifies the code and doesn't change the current behaviour, the "seq" counter is always even so read_seqbegin_or_lock() can never take the lock. Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/
1 parent 1702e06 commit df91b9d

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

fs/afs/inode.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,10 @@ bool afs_check_validity(struct afs_vnode *vnode)
629629
enum afs_cb_break_reason need_clear = afs_cb_break_no_break;
630630
time64_t now = ktime_get_real_seconds();
631631
unsigned int cb_break;
632-
int seq = 0;
632+
int seq;
633633

634634
do {
635-
read_seqbegin_or_lock(&vnode->cb_lock, &seq);
635+
seq = read_seqbegin(&vnode->cb_lock);
636636
cb_break = vnode->cb_break;
637637

638638
if (test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags)) {
@@ -650,9 +650,7 @@ bool afs_check_validity(struct afs_vnode *vnode)
650650
need_clear = afs_cb_break_no_promise;
651651
}
652652

653-
} while (need_seqretry(&vnode->cb_lock, seq));
654-
655-
done_seqretry(&vnode->cb_lock, seq);
653+
} while (read_seqretry(&vnode->cb_lock, seq));
656654

657655
if (need_clear == afs_cb_break_no_break)
658656
return true;
@@ -755,7 +753,7 @@ int afs_getattr(struct mnt_idmap *idmap, const struct path *path,
755753
struct inode *inode = d_inode(path->dentry);
756754
struct afs_vnode *vnode = AFS_FS_I(inode);
757755
struct key *key;
758-
int ret, seq = 0;
756+
int ret, seq;
759757

760758
_enter("{ ino=%lu v=%u }", inode->i_ino, inode->i_generation);
761759

@@ -772,7 +770,7 @@ int afs_getattr(struct mnt_idmap *idmap, const struct path *path,
772770
}
773771

774772
do {
775-
read_seqbegin_or_lock(&vnode->cb_lock, &seq);
773+
seq = read_seqbegin(&vnode->cb_lock);
776774
generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
777775
if (test_bit(AFS_VNODE_SILLY_DELETED, &vnode->flags) &&
778776
stat->nlink > 0)
@@ -784,9 +782,8 @@ int afs_getattr(struct mnt_idmap *idmap, const struct path *path,
784782
*/
785783
if (S_ISDIR(inode->i_mode))
786784
stat->size = vnode->netfs.remote_i_size;
787-
} while (need_seqretry(&vnode->cb_lock, seq));
785+
} while (read_seqretry(&vnode->cb_lock, seq));
788786

789-
done_seqretry(&vnode->cb_lock, seq);
790787
return 0;
791788
}
792789

0 commit comments

Comments
 (0)