History

9p: fix EBADF errors in cached mode

cached operations sometimes need to do invalid operations (e.g. read on a write only file) Historic fscache had added a "writeback fid", a special handle opened RW as root, for this. The conversion to new fscache missed that bit. This commit reinstates a slightly lesser variant of the original code that uses the writeback fid for partial pages backfills if the regular user fid had been open as WRONLY, and thus would lack read permissions.

Dominique Martinet committed 4 years ago

Commit b0017601 parent 2a3dcbc1 file · +13 −0Browse files

Unified · Split

fs/9p/vfs_addr.c+13−0
@@ -58,8 +58,21 @@ static void v9fs_issue_read(struct netfs_io_subrequest *subreq) · 57 unmodified lines
58 */58 */
59static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file)59static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file)
60{60{
61 struct inode *inode = file_inode(file);
62 struct v9fs_inode *v9inode = V9FS_I(inode);
61 struct p9_fid *fid = file->private_data;63 struct p9_fid *fid = file->private_data;
62 64
65 BUG_ON(!fid);
66
67 /* we might need to read from a fid that was opened write-only
68 * for read-modify-write of page cache, use the writeback fid
69 * for that */
70 if (rreq->origin == NETFS_READ_FOR_WRITE &&
71 (fid->mode & O_ACCMODE) == O_WRONLY) {
72 fid = v9inode->writeback_fid;
73 BUG_ON(!fid);
74 }
75
63 refcount_inc(&fid->count);76 refcount_inc(&fid->count);
64 rreq->netfs_priv = fid;77 rreq->netfs_priv = fid;
65 return 0;78 return 0;