diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-04 12:06:13 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-04 12:06:13 -0400 |
| commit | 15c83d26e16d19522ebba2a8c38b77fbe64e6ca3 (patch) | |
| tree | 7ee9aef00a9c3564512847379e76ae2773125863 | |
| parent | 8e1a254099dcb7ea5eacd503799b641208300ff3 (diff) | |
| parent | 698fa1d163c560343b8012a0a916440d076b6c8a (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
Pull fuse bugfixes from Miklos Szeredi:
"This contains two more fixes by Maxim for writeback/truncate races and
fixes for RCU walk in fuse_dentry_revalidate()"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse:
fuse: no RCU mode in fuse_access()
fuse: readdirplus: fix RCU walk
fuse: don't check_submounts_and_drop() in RCU walk
fuse: fix fallocate vs. ftruncate race
fuse: wait for writeback in fuse_file_fallocate()
| -rw-r--r-- | fs/fuse/dir.c | 20 | ||||
| -rw-r--r-- | fs/fuse/file.c | 23 | ||||
| -rw-r--r-- | fs/fuse/fuse_i.h | 2 |
3 files changed, 32 insertions, 13 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 62b43b577bfc..b7989f2ab4c4 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
| @@ -182,6 +182,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) | |||
| 182 | struct inode *inode; | 182 | struct inode *inode; |
| 183 | struct dentry *parent; | 183 | struct dentry *parent; |
| 184 | struct fuse_conn *fc; | 184 | struct fuse_conn *fc; |
| 185 | struct fuse_inode *fi; | ||
| 185 | int ret; | 186 | int ret; |
| 186 | 187 | ||
| 187 | inode = ACCESS_ONCE(entry->d_inode); | 188 | inode = ACCESS_ONCE(entry->d_inode); |
| @@ -228,7 +229,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) | |||
| 228 | if (!err && !outarg.nodeid) | 229 | if (!err && !outarg.nodeid) |
| 229 | err = -ENOENT; | 230 | err = -ENOENT; |
| 230 | if (!err) { | 231 | if (!err) { |
| 231 | struct fuse_inode *fi = get_fuse_inode(inode); | 232 | fi = get_fuse_inode(inode); |
| 232 | if (outarg.nodeid != get_node_id(inode)) { | 233 | if (outarg.nodeid != get_node_id(inode)) { |
| 233 | fuse_queue_forget(fc, forget, outarg.nodeid, 1); | 234 | fuse_queue_forget(fc, forget, outarg.nodeid, 1); |
| 234 | goto invalid; | 235 | goto invalid; |
| @@ -246,8 +247,11 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) | |||
| 246 | attr_version); | 247 | attr_version); |
| 247 | fuse_change_entry_timeout(entry, &outarg); | 248 | fuse_change_entry_timeout(entry, &outarg); |
| 248 | } else if (inode) { | 249 | } else if (inode) { |
| 249 | fc = get_fuse_conn(inode); | 250 | fi = get_fuse_inode(inode); |
| 250 | if (fc->readdirplus_auto) { | 251 | if (flags & LOOKUP_RCU) { |
| 252 | if (test_bit(FUSE_I_INIT_RDPLUS, &fi->state)) | ||
| 253 | return -ECHILD; | ||
| 254 | } else if (test_and_clear_bit(FUSE_I_INIT_RDPLUS, &fi->state)) { | ||
| 251 | parent = dget_parent(entry); | 255 | parent = dget_parent(entry); |
| 252 | fuse_advise_use_readdirplus(parent->d_inode); | 256 | fuse_advise_use_readdirplus(parent->d_inode); |
| 253 | dput(parent); | 257 | dput(parent); |
| @@ -259,7 +263,8 @@ out: | |||
| 259 | 263 | ||
| 260 | invalid: | 264 | invalid: |
| 261 | ret = 0; | 265 | ret = 0; |
| 262 | if (check_submounts_and_drop(entry) != 0) | 266 | |
| 267 | if (!(flags & LOOKUP_RCU) && check_submounts_and_drop(entry) != 0) | ||
| 263 | ret = 1; | 268 | ret = 1; |
| 264 | goto out; | 269 | goto out; |
| 265 | } | 270 | } |
| @@ -1063,6 +1068,8 @@ static int fuse_access(struct inode *inode, int mask) | |||
| 1063 | struct fuse_access_in inarg; | 1068 | struct fuse_access_in inarg; |
| 1064 | int err; | 1069 | int err; |
| 1065 | 1070 | ||
| 1071 | BUG_ON(mask & MAY_NOT_BLOCK); | ||
| 1072 | |||
| 1066 | if (fc->no_access) | 1073 | if (fc->no_access) |
| 1067 | return 0; | 1074 | return 0; |
| 1068 | 1075 | ||
| @@ -1150,9 +1157,6 @@ static int fuse_permission(struct inode *inode, int mask) | |||
| 1150 | noticed immediately, only after the attribute | 1157 | noticed immediately, only after the attribute |
| 1151 | timeout has expired */ | 1158 | timeout has expired */ |
| 1152 | } else if (mask & (MAY_ACCESS | MAY_CHDIR)) { | 1159 | } else if (mask & (MAY_ACCESS | MAY_CHDIR)) { |
| 1153 | if (mask & MAY_NOT_BLOCK) | ||
| 1154 | return -ECHILD; | ||
| 1155 | |||
| 1156 | err = fuse_access(inode, mask); | 1160 | err = fuse_access(inode, mask); |
| 1157 | } else if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) { | 1161 | } else if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) { |
| 1158 | if (!(inode->i_mode & S_IXUGO)) { | 1162 | if (!(inode->i_mode & S_IXUGO)) { |
| @@ -1291,6 +1295,8 @@ static int fuse_direntplus_link(struct file *file, | |||
| 1291 | } | 1295 | } |
| 1292 | 1296 | ||
| 1293 | found: | 1297 | found: |
| 1298 | if (fc->readdirplus_auto) | ||
| 1299 | set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state); | ||
| 1294 | fuse_change_entry_timeout(dentry, o); | 1300 | fuse_change_entry_timeout(dentry, o); |
| 1295 | 1301 | ||
| 1296 | err = 0; | 1302 | err = 0; |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index d409deafc67b..4598345ab87d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
| @@ -2467,6 +2467,7 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, | |||
| 2467 | { | 2467 | { |
| 2468 | struct fuse_file *ff = file->private_data; | 2468 | struct fuse_file *ff = file->private_data; |
| 2469 | struct inode *inode = file->f_inode; | 2469 | struct inode *inode = file->f_inode; |
| 2470 | struct fuse_inode *fi = get_fuse_inode(inode); | ||
| 2470 | struct fuse_conn *fc = ff->fc; | 2471 | struct fuse_conn *fc = ff->fc; |
| 2471 | struct fuse_req *req; | 2472 | struct fuse_req *req; |
| 2472 | struct fuse_fallocate_in inarg = { | 2473 | struct fuse_fallocate_in inarg = { |
| @@ -2484,10 +2485,20 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, | |||
| 2484 | 2485 | ||
| 2485 | if (lock_inode) { | 2486 | if (lock_inode) { |
| 2486 | mutex_lock(&inode->i_mutex); | 2487 | mutex_lock(&inode->i_mutex); |
| 2487 | if (mode & FALLOC_FL_PUNCH_HOLE) | 2488 | if (mode & FALLOC_FL_PUNCH_HOLE) { |
| 2488 | fuse_set_nowrite(inode); | 2489 | loff_t endbyte = offset + length - 1; |
| 2490 | err = filemap_write_and_wait_range(inode->i_mapping, | ||
| 2491 | offset, endbyte); | ||
| 2492 | if (err) | ||
| 2493 | goto out; | ||
| 2494 | |||
| 2495 | fuse_sync_writes(inode); | ||
| 2496 | } | ||
| 2489 | } | 2497 | } |
| 2490 | 2498 | ||
| 2499 | if (!(mode & FALLOC_FL_KEEP_SIZE)) | ||
| 2500 | set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); | ||
| 2501 | |||
| 2491 | req = fuse_get_req_nopages(fc); | 2502 | req = fuse_get_req_nopages(fc); |
| 2492 | if (IS_ERR(req)) { | 2503 | if (IS_ERR(req)) { |
| 2493 | err = PTR_ERR(req); | 2504 | err = PTR_ERR(req); |
| @@ -2520,11 +2531,11 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, | |||
| 2520 | fuse_invalidate_attr(inode); | 2531 | fuse_invalidate_attr(inode); |
| 2521 | 2532 | ||
| 2522 | out: | 2533 | out: |
| 2523 | if (lock_inode) { | 2534 | if (!(mode & FALLOC_FL_KEEP_SIZE)) |
| 2524 | if (mode & FALLOC_FL_PUNCH_HOLE) | 2535 | clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); |
| 2525 | fuse_release_nowrite(inode); | 2536 | |
| 2537 | if (lock_inode) | ||
| 2526 | mutex_unlock(&inode->i_mutex); | 2538 | mutex_unlock(&inode->i_mutex); |
| 2527 | } | ||
| 2528 | 2539 | ||
| 2529 | return err; | 2540 | return err; |
| 2530 | } | 2541 | } |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 5ced199b50bb..5b9e6f3b6aef 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
| @@ -115,6 +115,8 @@ struct fuse_inode { | |||
| 115 | enum { | 115 | enum { |
| 116 | /** Advise readdirplus */ | 116 | /** Advise readdirplus */ |
| 117 | FUSE_I_ADVISE_RDPLUS, | 117 | FUSE_I_ADVISE_RDPLUS, |
| 118 | /** Initialized with readdirplus */ | ||
| 119 | FUSE_I_INIT_RDPLUS, | ||
| 118 | /** An operation changing file size is in progress */ | 120 | /** An operation changing file size is in progress */ |
| 119 | FUSE_I_SIZE_UNSTABLE, | 121 | FUSE_I_SIZE_UNSTABLE, |
| 120 | }; | 122 | }; |
