diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2007-11-28 19:21:59 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-29 12:24:54 -0500 |
commit | 7dca9fd39f7d4605ac178a67bb1772381056917d (patch) | |
tree | 8a2f49e872a900819c7067bbe8ed118f88241f07 /fs/fuse | |
parent | bcb4be809d2a804ff040d95db4a664113833e702 (diff) |
fuse: cleanup: add fuse_get_attr_version()
Extract repeated code into helper function, as suggested by Akpm.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fuse')
-rw-r--r-- | fs/fuse/dir.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 7b3df35cf196..c84f825b57e7 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -132,6 +132,21 @@ static void fuse_lookup_init(struct fuse_req *req, struct inode *dir, | |||
132 | req->out.args[0].value = outarg; | 132 | req->out.args[0].value = outarg; |
133 | } | 133 | } |
134 | 134 | ||
135 | static u64 fuse_get_attr_version(struct fuse_conn *fc) | ||
136 | { | ||
137 | u64 curr_version; | ||
138 | |||
139 | /* | ||
140 | * The spin lock isn't actually needed on 64bit archs, but we | ||
141 | * don't yet care too much about such optimizations. | ||
142 | */ | ||
143 | spin_lock(&fc->lock); | ||
144 | curr_version = fc->attr_version; | ||
145 | spin_unlock(&fc->lock); | ||
146 | |||
147 | return curr_version; | ||
148 | } | ||
149 | |||
135 | /* | 150 | /* |
136 | * Check whether the dentry is still valid | 151 | * Check whether the dentry is still valid |
137 | * | 152 | * |
@@ -171,9 +186,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) | |||
171 | return 0; | 186 | return 0; |
172 | } | 187 | } |
173 | 188 | ||
174 | spin_lock(&fc->lock); | 189 | attr_version = fuse_get_attr_version(fc); |
175 | attr_version = fc->attr_version; | ||
176 | spin_unlock(&fc->lock); | ||
177 | 190 | ||
178 | parent = dget_parent(entry); | 191 | parent = dget_parent(entry); |
179 | fuse_lookup_init(req, parent->d_inode, entry, &outarg); | 192 | fuse_lookup_init(req, parent->d_inode, entry, &outarg); |
@@ -264,9 +277,7 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, | |||
264 | return ERR_PTR(PTR_ERR(forget_req)); | 277 | return ERR_PTR(PTR_ERR(forget_req)); |
265 | } | 278 | } |
266 | 279 | ||
267 | spin_lock(&fc->lock); | 280 | attr_version = fuse_get_attr_version(fc); |
268 | attr_version = fc->attr_version; | ||
269 | spin_unlock(&fc->lock); | ||
270 | 281 | ||
271 | fuse_lookup_init(req, dir, entry, &outarg); | 282 | fuse_lookup_init(req, dir, entry, &outarg); |
272 | request_send(fc, req); | 283 | request_send(fc, req); |
@@ -733,9 +744,7 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat, | |||
733 | if (IS_ERR(req)) | 744 | if (IS_ERR(req)) |
734 | return PTR_ERR(req); | 745 | return PTR_ERR(req); |
735 | 746 | ||
736 | spin_lock(&fc->lock); | 747 | attr_version = fuse_get_attr_version(fc); |
737 | attr_version = fc->attr_version; | ||
738 | spin_unlock(&fc->lock); | ||
739 | 748 | ||
740 | memset(&inarg, 0, sizeof(inarg)); | 749 | memset(&inarg, 0, sizeof(inarg)); |
741 | memset(&outarg, 0, sizeof(outarg)); | 750 | memset(&outarg, 0, sizeof(outarg)); |