9p pull request for inclusion in 5.7

- Fix read with O_NONBLOCK to allow incomplete read and return immediately
 - Rest is just cleanup (indent, unused field in struct, extra semicolon)
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE/IPbcYBuWt0zoYhOq06b7GqY5nAFAl6LCyEACgkQq06b7GqY
 5nAAQg//ThE/rojrB74S8yaD3sJlfsT+BoMzGDeos9FGdsHpO8t1ISUiheAcUn/Y
 a6igfJxTefxEO5SWqvsGEousRl0sRTyLo8RuQ2CC7+zKN8Ou+eG+4s2QXfDxBD+p
 xJGJrsWD2SkQ98/hkxDY6d31BM9iQGvpvVp/c9qLwtvTlnvEMXll0JiACcnmiPRt
 z92bx8QkaPlt399qv7LltfHftxCHOMcieQlYAF3wDjLauiEdDWysiMn0NIC2izwY
 hPlsVCiV504yhvQFcXVnmbWVJe88THlBVVjuVAi9IwpU8D2+1UK1kM/yiyVkYml+
 U4JC7ZBQoqw2obSLPk5mZ6E7nGWfWnIBpt/B9dO7akP8pS9bv+uCjwg65tFEop5/
 z9nuyjoQT/dEoThveeoEoxpIbyd690n1vbhcTdGDFDX5nfglrxj0S6bNVW0k6e41
 9aPwWzAfU9Ip9GHwE6Ewf/y88mMI7rCP+o/pC8XkUUGiV+foFt3oO5wCcvGbxwgJ
 nnZ5oY+Ren/QXOmq/cN3RUWJvTRbc8TDBm6Fa0iGkk7d1OUBuRTWuBUXvxHMpO3A
 xHapDRddPcrZ9QQSJZGvMSYwG0ZUZ6MRL2qTU4X/3sIi0giApFkRMpmmo0HjvMAf
 PIFl2MG2Ok4A8yWQN98AMXy8vgs6ql6+Wb3W0b5dNFsAGEk7f9U=
 =wAe5
 -----END PGP SIGNATURE-----

Merge tag '9p-for-5.7' of git://github.com/martinetd/linux

Pull 9p updates from Dominique Martinet:
 "Not much new, but a few patches for this cycle:

   - Fix read with O_NONBLOCK to allow incomplete read and return
     immediately

   - Rest is just cleanup (indent, unused field in struct, extra
     semicolon)"

* tag '9p-for-5.7' of git://github.com/martinetd/linux:
  net/9p: remove unused p9_req_t aux field
  9p: read only once on O_NONBLOCK
  9pnet: allow making incomplete read requests
  9p: Remove unneeded semicolon
  9p: Fix Kconfig indentation
This commit is contained in:
Linus Torvalds 2020-04-06 08:46:59 -07:00
commit e14679b62d
5 changed files with 94 additions and 79 deletions

View File

@ -32,13 +32,13 @@ endif
config 9P_FS_SECURITY config 9P_FS_SECURITY
bool "9P Security Labels" bool "9P Security Labels"
depends on 9P_FS depends on 9P_FS
help help
Security labels support alternative access control models Security labels support alternative access control models
implemented by security modules like SELinux. This option implemented by security modules like SELinux. This option
enables an extended attribute handler for file security enables an extended attribute handler for file security
labels in the 9P filesystem. labels in the 9P filesystem.
If you are not using a security module that requires using If you are not using a security module that requires using
extended attributes for file security labels, say N. extended attributes for file security labels, say N.

View File

@ -388,7 +388,10 @@ v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
p9_debug(P9_DEBUG_VFS, "count %zu offset %lld\n", p9_debug(P9_DEBUG_VFS, "count %zu offset %lld\n",
iov_iter_count(to), iocb->ki_pos); iov_iter_count(to), iocb->ki_pos);
ret = p9_client_read(fid, iocb->ki_pos, to, &err); if (iocb->ki_filp->f_flags & O_NONBLOCK)
ret = p9_client_read_once(fid, iocb->ki_pos, to, &err);
else
ret = p9_client_read(fid, iocb->ki_pos, to, &err);
if (!ret) if (!ret)
return err; return err;

View File

@ -143,7 +143,7 @@ static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses,
default: default:
p9_debug(P9_DEBUG_ERROR, "Unknown special type %c %s\n", p9_debug(P9_DEBUG_ERROR, "Unknown special type %c %s\n",
type, stat->extension); type, stat->extension);
}; }
*rdev = MKDEV(major, minor); *rdev = MKDEV(major, minor);
} else } else
res |= S_IFREG; res |= S_IFREG;

View File

@ -73,7 +73,6 @@ enum p9_req_status_t {
* @wq: wait_queue for the client to block on for this request * @wq: wait_queue for the client to block on for this request
* @tc: the request fcall structure * @tc: the request fcall structure
* @rc: the response fcall structure * @rc: the response fcall structure
* @aux: transport specific data (provided for trans_fd migration)
* @req_list: link for higher level objects to chain requests * @req_list: link for higher level objects to chain requests
*/ */
struct p9_req_t { struct p9_req_t {
@ -83,7 +82,6 @@ struct p9_req_t {
wait_queue_head_t wq; wait_queue_head_t wq;
struct p9_fcall tc; struct p9_fcall tc;
struct p9_fcall rc; struct p9_fcall rc;
void *aux;
struct list_head req_list; struct list_head req_list;
}; };
@ -200,6 +198,8 @@ int p9_client_fsync(struct p9_fid *fid, int datasync);
int p9_client_remove(struct p9_fid *fid); int p9_client_remove(struct p9_fid *fid);
int p9_client_unlinkat(struct p9_fid *dfid, const char *name, int flags); int p9_client_unlinkat(struct p9_fid *dfid, const char *name, int flags);
int p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err); int p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err);
int p9_client_read_once(struct p9_fid *fid, u64 offset, struct iov_iter *to,
int *err);
int p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err); int p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err);
int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset); int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset);
int p9dirent_read(struct p9_client *clnt, char *buf, int len, int p9dirent_read(struct p9_client *clnt, char *buf, int len,

View File

@ -1549,83 +1549,95 @@ EXPORT_SYMBOL(p9_client_unlinkat);
int int
p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err) p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err)
{ {
struct p9_client *clnt = fid->clnt;
struct p9_req_t *req;
int total = 0; int total = 0;
*err = 0; *err = 0;
p9_debug(P9_DEBUG_9P, ">>> TREAD fid %d offset %llu %d\n",
fid->fid, (unsigned long long) offset, (int)iov_iter_count(to));
while (iov_iter_count(to)) { while (iov_iter_count(to)) {
int count = iov_iter_count(to); int count;
int rsize, non_zc = 0;
char *dataptr;
rsize = fid->iounit; count = p9_client_read_once(fid, offset, to, err);
if (!rsize || rsize > clnt->msize-P9_IOHDRSZ) if (!count || *err)
rsize = clnt->msize - P9_IOHDRSZ;
if (count < rsize)
rsize = count;
/* Don't bother zerocopy for small IO (< 1024) */
if (clnt->trans_mod->zc_request && rsize > 1024) {
/*
* response header len is 11
* PDU Header(7) + IO Size (4)
*/
req = p9_client_zc_rpc(clnt, P9_TREAD, to, NULL, rsize,
0, 11, "dqd", fid->fid,
offset, rsize);
} else {
non_zc = 1;
req = p9_client_rpc(clnt, P9_TREAD, "dqd", fid->fid, offset,
rsize);
}
if (IS_ERR(req)) {
*err = PTR_ERR(req);
break; break;
} offset += count;
total += count;
*err = p9pdu_readf(&req->rc, clnt->proto_version,
"D", &count, &dataptr);
if (*err) {
trace_9p_protocol_dump(clnt, &req->rc);
p9_tag_remove(clnt, req);
break;
}
if (rsize < count) {
pr_err("bogus RREAD count (%d > %d)\n", count, rsize);
count = rsize;
}
p9_debug(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
if (!count) {
p9_tag_remove(clnt, req);
break;
}
if (non_zc) {
int n = copy_to_iter(dataptr, count, to);
total += n;
offset += n;
if (n != count) {
*err = -EFAULT;
p9_tag_remove(clnt, req);
break;
}
} else {
iov_iter_advance(to, count);
total += count;
offset += count;
}
p9_tag_remove(clnt, req);
} }
return total; return total;
} }
EXPORT_SYMBOL(p9_client_read); EXPORT_SYMBOL(p9_client_read);
int
p9_client_read_once(struct p9_fid *fid, u64 offset, struct iov_iter *to,
int *err)
{
struct p9_client *clnt = fid->clnt;
struct p9_req_t *req;
int count = iov_iter_count(to);
int rsize, non_zc = 0;
char *dataptr;
*err = 0;
p9_debug(P9_DEBUG_9P, ">>> TREAD fid %d offset %llu %d\n",
fid->fid, (unsigned long long) offset, (int)iov_iter_count(to));
rsize = fid->iounit;
if (!rsize || rsize > clnt->msize - P9_IOHDRSZ)
rsize = clnt->msize - P9_IOHDRSZ;
if (count < rsize)
rsize = count;
/* Don't bother zerocopy for small IO (< 1024) */
if (clnt->trans_mod->zc_request && rsize > 1024) {
/* response header len is 11
* PDU Header(7) + IO Size (4)
*/
req = p9_client_zc_rpc(clnt, P9_TREAD, to, NULL, rsize,
0, 11, "dqd", fid->fid,
offset, rsize);
} else {
non_zc = 1;
req = p9_client_rpc(clnt, P9_TREAD, "dqd", fid->fid, offset,
rsize);
}
if (IS_ERR(req)) {
*err = PTR_ERR(req);
return 0;
}
*err = p9pdu_readf(&req->rc, clnt->proto_version,
"D", &count, &dataptr);
if (*err) {
trace_9p_protocol_dump(clnt, &req->rc);
p9_tag_remove(clnt, req);
return 0;
}
if (rsize < count) {
pr_err("bogus RREAD count (%d > %d)\n", count, rsize);
count = rsize;
}
p9_debug(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
if (!count) {
p9_tag_remove(clnt, req);
return 0;
}
if (non_zc) {
int n = copy_to_iter(dataptr, count, to);
if (n != count) {
*err = -EFAULT;
p9_tag_remove(clnt, req);
return n;
}
} else {
iov_iter_advance(to, count);
}
p9_tag_remove(clnt, req);
return count;
}
EXPORT_SYMBOL(p9_client_read_once);
int int
p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err) p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err)
{ {