Skip to content

Commit 2e64ff1

Browse files
chadaustinMiklos Szeredi
authored andcommitted
fuse: continue to send FUSE_RELEASEDIR when FUSE_OPEN returns ENOSYS
When FUSE_OPEN returns ENOSYS, the no_open bit is set on the connection. Because the FUSE_RELEASE and FUSE_RELEASEDIR paths share code, this incorrectly caused the FUSE_RELEASEDIR request to be dropped and never sent to userspace. Pass an isdir bool to distinguish between FUSE_RELEASE and FUSE_RELEASEDIR inside of fuse_file_put. Fixes: 7678ac5 ("fuse: support clients that don't implement 'open'") Cc: <stable@vger.kernel.org> # v3.14 Signed-off-by: Chad Austin <chadaustin@fb.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent d72f70d commit 2e64ff1

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

‎fs/fuse/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ static int fuse_dir_open(struct inode *inode, struct file *file)
12431243

12441244
static int fuse_dir_release(struct inode *inode, struct file *file)
12451245
{
1246-
fuse_release_common(file, FUSE_RELEASEDIR);
1246+
fuse_release_common(file, true);
12471247

12481248
return 0;
12491249
}

‎fs/fuse/file.c‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ static void fuse_release_end(struct fuse_conn *fc, struct fuse_req *req)
8989
iput(req->misc.release.inode);
9090
}
9191

92-
static void fuse_file_put(struct fuse_file *ff, bool sync)
92+
static void fuse_file_put(struct fuse_file *ff, bool sync, bool isdir)
9393
{
9494
if (refcount_dec_and_test(&ff->count)) {
9595
struct fuse_req *req = ff->reserved_req;
9696

97-
if (ff->fc->no_open) {
97+
if (ff->fc->no_open && !isdir) {
9898
/*
9999
* Drop the release request when client does not
100100
* implement 'open'
@@ -247,10 +247,11 @@ static void fuse_prepare_release(struct fuse_file *ff, int flags, int opcode)
247247
req->in.args[0].value = inarg;
248248
}
249249

250-
void fuse_release_common(struct file *file, int opcode)
250+
void fuse_release_common(struct file *file, bool isdir)
251251
{
252252
struct fuse_file *ff = file->private_data;
253253
struct fuse_req *req = ff->reserved_req;
254+
int opcode = isdir ? FUSE_RELEASEDIR : FUSE_RELEASE;
254255

255256
fuse_prepare_release(ff, file->f_flags, opcode);
256257

@@ -272,7 +273,7 @@ void fuse_release_common(struct file *file, int opcode)
272273
* synchronous RELEASE is allowed (and desirable) in this case
273274
* because the server can be trusted not to screw up.
274275
*/
275-
fuse_file_put(ff, ff->fc->destroy_req != NULL);
276+
fuse_file_put(ff, ff->fc->destroy_req != NULL, isdir);
276277
}
277278

278279
static int fuse_open(struct inode *inode, struct file *file)
@@ -288,7 +289,7 @@ static int fuse_release(struct inode *inode, struct file *file)
288289
if (fc->writeback_cache)
289290
write_inode_now(inode, 1);
290291

291-
fuse_release_common(file, FUSE_RELEASE);
292+
fuse_release_common(file, false);
292293

293294
/* return value is ignored by VFS */
294295
return 0;
@@ -302,7 +303,7 @@ void fuse_sync_release(struct fuse_file *ff, int flags)
302303
* iput(NULL) is a no-op and since the refcount is 1 and everything's
303304
* synchronous, we are fine with not doing igrab() here"
304305
*/
305-
fuse_file_put(ff, true);
306+
fuse_file_put(ff, true, false);
306307
}
307308
EXPORT_SYMBOL_GPL(fuse_sync_release);
308309

@@ -808,7 +809,7 @@ static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req)
808809
put_page(page);
809810
}
810811
if (req->ff)
811-
fuse_file_put(req->ff, false);
812+
fuse_file_put(req->ff, false, false);
812813
}
813814

814815
static void fuse_send_readpages(struct fuse_req *req, struct file *file)
@@ -1461,7 +1462,7 @@ static void fuse_writepage_free(struct fuse_conn *fc, struct fuse_req *req)
14611462
__free_page(req->pages[i]);
14621463

14631464
if (req->ff)
1464-
fuse_file_put(req->ff, false);
1465+
fuse_file_put(req->ff, false, false);
14651466
}
14661467

14671468
static void fuse_writepage_finish(struct fuse_conn *fc, struct fuse_req *req)
@@ -1620,7 +1621,7 @@ int fuse_write_inode(struct inode *inode, struct writeback_control *wbc)
16201621
ff = __fuse_write_file_get(fc, fi);
16211622
err = fuse_flush_times(inode, ff);
16221623
if (ff)
1623-
fuse_file_put(ff, 0);
1624+
fuse_file_put(ff, false, false);
16241625

16251626
return err;
16261627
}
@@ -1941,7 +1942,7 @@ static int fuse_writepages(struct address_space *mapping,
19411942
err = 0;
19421943
}
19431944
if (data.ff)
1944-
fuse_file_put(data.ff, false);
1945+
fuse_file_put(data.ff, false, false);
19451946

19461947
kfree(data.orig_pages);
19471948
out:

‎fs/fuse/fuse_i.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ void fuse_sync_release(struct fuse_file *ff, int flags);
822822
/**
823823
* Send RELEASE or RELEASEDIR request
824824
*/
825-
void fuse_release_common(struct file *file, int opcode);
825+
void fuse_release_common(struct file *file, bool isdir);
826826

827827
/**
828828
* Send FSYNC or FSYNCDIR request

0 commit comments

Comments
 (0)