Skip to content

Commit 81dcc79

Browse files
committed
Merge tag 'fuse-fixes-6.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
Pull fuse fixes from Miklos Szeredi: - Fix cached size after passthrough writes This fix needed a trivial change in the backing-file API, which resulted in some non-fuse files being touched. - Revert a commit meant as a cleanup but which triggered a WARNING - Remove a stray debug line left-over * tag 'fuse-fixes-6.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse: fuse: remove stray debug line Revert "fuse: move initialization of fuse_file to fuse_writepages() instead of in callback" fuse: update inode size after extending passthrough write fs: pass offset and result to backing_file end_write() callback
2 parents f647053 + d34a557 commit 81dcc79

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

fs/backing-file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct backing_aio {
8080
refcount_t ref;
8181
struct kiocb *orig_iocb;
8282
/* used for aio completion */
83-
void (*end_write)(struct file *);
83+
void (*end_write)(struct file *, loff_t, ssize_t);
8484
struct work_struct work;
8585
long res;
8686
};
@@ -109,7 +109,7 @@ static void backing_aio_cleanup(struct backing_aio *aio, long res)
109109
struct kiocb *orig_iocb = aio->orig_iocb;
110110

111111
if (aio->end_write)
112-
aio->end_write(orig_iocb->ki_filp);
112+
aio->end_write(orig_iocb->ki_filp, iocb->ki_pos, res);
113113

114114
orig_iocb->ki_pos = iocb->ki_pos;
115115
backing_aio_put(aio);
@@ -239,7 +239,7 @@ ssize_t backing_file_write_iter(struct file *file, struct iov_iter *iter,
239239

240240
ret = vfs_iter_write(file, iter, &iocb->ki_pos, rwf);
241241
if (ctx->end_write)
242-
ctx->end_write(ctx->user_file);
242+
ctx->end_write(ctx->user_file, iocb->ki_pos, ret);
243243
} else {
244244
struct backing_aio *aio;
245245

@@ -317,7 +317,7 @@ ssize_t backing_file_splice_write(struct pipe_inode_info *pipe,
317317
revert_creds(old_cred);
318318

319319
if (ctx->end_write)
320-
ctx->end_write(ctx->user_file);
320+
ctx->end_write(ctx->user_file, ppos ? *ppos : 0, ret);
321321

322322
return ret;
323323
}

fs/fuse/file.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,13 @@ static int fuse_writepages_fill(struct folio *folio,
22882288
struct folio *tmp_folio;
22892289
int err;
22902290

2291+
if (!data->ff) {
2292+
err = -EIO;
2293+
data->ff = fuse_write_file_get(fi);
2294+
if (!data->ff)
2295+
goto out_unlock;
2296+
}
2297+
22912298
if (wpa && fuse_writepage_need_send(fc, &folio->page, ap, data)) {
22922299
fuse_writepages_send(data);
22932300
data->wpa = NULL;
@@ -2351,23 +2358,21 @@ static int fuse_writepages(struct address_space *mapping,
23512358
struct writeback_control *wbc)
23522359
{
23532360
struct inode *inode = mapping->host;
2354-
struct fuse_inode *fi = get_fuse_inode(inode);
23552361
struct fuse_conn *fc = get_fuse_conn(inode);
23562362
struct fuse_fill_wb_data data;
23572363
int err;
23582364

2365+
err = -EIO;
23592366
if (fuse_is_bad(inode))
2360-
return -EIO;
2367+
goto out;
23612368

23622369
if (wbc->sync_mode == WB_SYNC_NONE &&
23632370
fc->num_background >= fc->congestion_threshold)
23642371
return 0;
23652372

23662373
data.inode = inode;
23672374
data.wpa = NULL;
2368-
data.ff = fuse_write_file_get(fi);
2369-
if (!data.ff)
2370-
return -EIO;
2375+
data.ff = NULL;
23712376

23722377
err = -ENOMEM;
23732378
data.orig_pages = kcalloc(fc->max_pages,
@@ -2381,10 +2386,11 @@ static int fuse_writepages(struct address_space *mapping,
23812386
WARN_ON(!data.wpa->ia.ap.num_pages);
23822387
fuse_writepages_send(&data);
23832388
}
2389+
if (data.ff)
2390+
fuse_file_put(data.ff, false);
23842391

23852392
kfree(data.orig_pages);
23862393
out:
2387-
fuse_file_put(data.ff, false);
23882394
return err;
23892395
}
23902396

fs/fuse/passthrough.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ static void fuse_file_accessed(struct file *file)
1818
fuse_invalidate_atime(inode);
1919
}
2020

21-
static void fuse_file_modified(struct file *file)
21+
static void fuse_passthrough_end_write(struct file *file, loff_t pos, ssize_t ret)
2222
{
2323
struct inode *inode = file_inode(file);
2424

25-
fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE);
25+
fuse_write_update_attr(inode, pos, ret);
2626
}
2727

2828
ssize_t fuse_passthrough_read_iter(struct kiocb *iocb, struct iov_iter *iter)
@@ -63,7 +63,7 @@ ssize_t fuse_passthrough_write_iter(struct kiocb *iocb,
6363
struct backing_file_ctx ctx = {
6464
.cred = ff->cred,
6565
.user_file = file,
66-
.end_write = fuse_file_modified,
66+
.end_write = fuse_passthrough_end_write,
6767
};
6868

6969
pr_debug("%s: backing_file=0x%p, pos=%lld, len=%zu\n", __func__,
@@ -110,7 +110,7 @@ ssize_t fuse_passthrough_splice_write(struct pipe_inode_info *pipe,
110110
struct backing_file_ctx ctx = {
111111
.cred = ff->cred,
112112
.user_file = out,
113-
.end_write = fuse_file_modified,
113+
.end_write = fuse_passthrough_end_write,
114114
};
115115

116116
pr_debug("%s: backing_file=0x%p, pos=%lld, len=%zu, flags=0x%x\n", __func__,
@@ -234,7 +234,6 @@ int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map)
234234
goto out;
235235

236236
backing_sb = file_inode(file)->i_sb;
237-
pr_info("%s: %x:%pD %i\n", __func__, backing_sb->s_dev, file, backing_sb->s_stack_depth);
238237
res = -ELOOP;
239238
if (backing_sb->s_stack_depth >= fc->max_stack_depth)
240239
goto out_fput;

fs/overlayfs/file.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ static void ovl_file_modified(struct file *file)
231231
ovl_copyattr(file_inode(file));
232232
}
233233

234+
static void ovl_file_end_write(struct file *file, loff_t pos, ssize_t ret)
235+
{
236+
ovl_file_modified(file);
237+
}
238+
234239
static void ovl_file_accessed(struct file *file)
235240
{
236241
struct inode *inode, *upperinode;
@@ -294,7 +299,7 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
294299
struct backing_file_ctx ctx = {
295300
.cred = ovl_creds(inode->i_sb),
296301
.user_file = file,
297-
.end_write = ovl_file_modified,
302+
.end_write = ovl_file_end_write,
298303
};
299304

300305
if (!iov_iter_count(iter))
@@ -364,7 +369,7 @@ static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out,
364369
struct backing_file_ctx ctx = {
365370
.cred = ovl_creds(inode->i_sb),
366371
.user_file = out,
367-
.end_write = ovl_file_modified,
372+
.end_write = ovl_file_end_write,
368373
};
369374

370375
inode_lock(inode);

include/linux/backing-file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct backing_file_ctx {
1616
const struct cred *cred;
1717
struct file *user_file;
1818
void (*accessed)(struct file *);
19-
void (*end_write)(struct file *);
19+
void (*end_write)(struct file *, loff_t, ssize_t);
2020
};
2121

2222
struct file *backing_file_open(const struct path *user_path, int flags,

0 commit comments

Comments
 (0)