Skip to content

Commit 23fdb19

Browse files
committed
Merge tag 'fuse-fixes-5.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
Pull fuse fixes from Miklos Szeredi: "Mostly virtiofs fixes, but also fixes a regression and couple of longstanding data/metadata writeback ordering issues" * tag 'fuse-fixes-5.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse: fuse: redundant get_fuse_inode() calls in fuse_writepages_fill() fuse: Add changelog entries for protocols 7.1 - 7.8 fuse: truncate pending writes on O_TRUNC fuse: flush dirty data/metadata before non-truncate setattr virtiofs: Remove set but not used variable 'fc' virtiofs: Retry request submission from worker context virtiofs: Count pending forgets as in_flight forgets virtiofs: Set FR_SENT flag only after request has been sent virtiofs: No need to check fpq->connected state virtiofs: Do not end request in submission context fuse: don't advise readdirplus for negative lookup fuse: don't dereference req->args on finished request virtio-fs: don't show mount options virtio-fs: Change module name to virtiofs.ko
2 parents 8005803 + 091d1a7 commit 23fdb19

File tree

8 files changed

+186
-65
lines changed

8 files changed

+186
-65
lines changed

fs/fuse/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
obj-$(CONFIG_FUSE_FS) += fuse.o
77
obj-$(CONFIG_CUSE) += cuse.o
8-
obj-$(CONFIG_VIRTIO_FS) += virtio_fs.o
8+
obj-$(CONFIG_VIRTIO_FS) += virtiofs.o
99

1010
fuse-objs := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o
11+
virtiofs-y += virtio_fs.o

fs/fuse/dev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,12 @@ static void flush_bg_queue(struct fuse_conn *fc)
276276
void fuse_request_end(struct fuse_conn *fc, struct fuse_req *req)
277277
{
278278
struct fuse_iqueue *fiq = &fc->iq;
279-
bool async = req->args->end;
279+
bool async;
280280

281281
if (test_and_set_bit(FR_FINISHED, &req->flags))
282282
goto put_request;
283+
284+
async = req->args->end;
283285
/*
284286
* test_and_set_bit() implies smp_mb() between bit
285287
* changing and below intr_entry check. Pairs with

fs/fuse/dir.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
405405
else
406406
fuse_invalidate_entry_cache(entry);
407407

408-
fuse_advise_use_readdirplus(dir);
408+
if (inode)
409+
fuse_advise_use_readdirplus(dir);
409410
return newent;
410411

411412
out_iput:
@@ -1521,6 +1522,19 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
15211522
is_truncate = true;
15221523
}
15231524

1525+
/* Flush dirty data/metadata before non-truncate SETATTR */
1526+
if (is_wb && S_ISREG(inode->i_mode) &&
1527+
attr->ia_valid &
1528+
(ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_MTIME_SET |
1529+
ATTR_TIMES_SET)) {
1530+
err = write_inode_now(inode, true);
1531+
if (err)
1532+
return err;
1533+
1534+
fuse_set_nowrite(inode);
1535+
fuse_release_nowrite(inode);
1536+
}
1537+
15241538
if (is_truncate) {
15251539
fuse_set_nowrite(inode);
15261540
set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);

fs/fuse/file.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,24 +217,28 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
217217
{
218218
struct fuse_conn *fc = get_fuse_conn(inode);
219219
int err;
220-
bool lock_inode = (file->f_flags & O_TRUNC) &&
220+
bool is_wb_truncate = (file->f_flags & O_TRUNC) &&
221221
fc->atomic_o_trunc &&
222222
fc->writeback_cache;
223223

224224
err = generic_file_open(inode, file);
225225
if (err)
226226
return err;
227227

228-
if (lock_inode)
228+
if (is_wb_truncate) {
229229
inode_lock(inode);
230+
fuse_set_nowrite(inode);
231+
}
230232

231233
err = fuse_do_open(fc, get_node_id(inode), file, isdir);
232234

233235
if (!err)
234236
fuse_finish_open(inode, file);
235237

236-
if (lock_inode)
238+
if (is_wb_truncate) {
239+
fuse_release_nowrite(inode);
237240
inode_unlock(inode);
241+
}
238242

239243
return err;
240244
}
@@ -1997,7 +2001,7 @@ static int fuse_writepages_fill(struct page *page,
19972001

19982002
if (!data->ff) {
19992003
err = -EIO;
2000-
data->ff = fuse_write_file_get(fc, get_fuse_inode(inode));
2004+
data->ff = fuse_write_file_get(fc, fi);
20012005
if (!data->ff)
20022006
goto out_unlock;
20032007
}
@@ -2042,8 +2046,6 @@ static int fuse_writepages_fill(struct page *page,
20422046
* under writeback, so we can release the page lock.
20432047
*/
20442048
if (data->wpa == NULL) {
2045-
struct fuse_inode *fi = get_fuse_inode(inode);
2046-
20472049
err = -ENOMEM;
20482050
wpa = fuse_writepage_args_alloc();
20492051
if (!wpa) {

fs/fuse/fuse_i.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ struct fuse_fs_context {
479479
bool destroy:1;
480480
bool no_control:1;
481481
bool no_force_umount:1;
482+
bool no_mount_options:1;
482483
unsigned int max_read;
483484
unsigned int blksize;
484485
const char *subtype;
@@ -713,6 +714,9 @@ struct fuse_conn {
713714
/** Do not allow MNT_FORCE umount */
714715
unsigned int no_force_umount:1;
715716

717+
/* Do not show mount options */
718+
unsigned int no_mount_options:1;
719+
716720
/** The number of requests waiting for completion */
717721
atomic_t num_waiting;
718722

fs/fuse/inode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@ static int fuse_show_options(struct seq_file *m, struct dentry *root)
558558
struct super_block *sb = root->d_sb;
559559
struct fuse_conn *fc = get_fuse_conn_super(sb);
560560

561+
if (fc->no_mount_options)
562+
return 0;
563+
561564
seq_printf(m, ",user_id=%u", from_kuid_munged(fc->user_ns, fc->user_id));
562565
seq_printf(m, ",group_id=%u", from_kgid_munged(fc->user_ns, fc->group_id));
563566
if (fc->default_permissions)
@@ -1180,6 +1183,7 @@ int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx)
11801183
fc->destroy = ctx->destroy;
11811184
fc->no_control = ctx->no_control;
11821185
fc->no_force_umount = ctx->no_force_umount;
1186+
fc->no_mount_options = ctx->no_mount_options;
11831187

11841188
err = -ENOMEM;
11851189
root = fuse_get_root_inode(sb, ctx->rootmode);

0 commit comments

Comments
 (0)