Skip to content

Commit 4e8c4c2

Browse files
jtlaytonidryomov
authored andcommitted
libceph: allow ceph_osdc_new_request to accept a multi-op read
Currently we have some special-casing for multi-op writes, but in the case of a read, we can't really handle it. All of the current multi-op callers call it with CEPH_OSD_FLAG_WRITE set. Have ceph_osdc_new_request check for CEPH_OSD_FLAG_READ and if it's set, allocate multiple reply ops instead of multiple request ops. If neither flag is set, return -EINVAL. Signed-off-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Xiubo Li <xiubli@redhat.com> Reviewed-and-tested-by: Luís Henriques <lhenriques@suse.de> Reviewed-by: Milind Changire <mchangir@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 69dd3b3 commit 4e8c4c2

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

net/ceph/osd_client.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,15 +1136,30 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
11361136
if (flags & CEPH_OSD_FLAG_WRITE)
11371137
req->r_data_offset = off;
11381138

1139-
if (num_ops > 1)
1139+
if (num_ops > 1) {
1140+
int num_req_ops, num_rep_ops;
1141+
11401142
/*
1141-
* This is a special case for ceph_writepages_start(), but it
1142-
* also covers ceph_uninline_data(). If more multi-op request
1143-
* use cases emerge, we will need a separate helper.
1143+
* If this is a multi-op write request, assume that we'll need
1144+
* request ops. If it's a multi-op read then assume we'll need
1145+
* reply ops. Anything else and call it -EINVAL.
11441146
*/
1145-
r = __ceph_osdc_alloc_messages(req, GFP_NOFS, num_ops, 0);
1146-
else
1147+
if (flags & CEPH_OSD_FLAG_WRITE) {
1148+
num_req_ops = num_ops;
1149+
num_rep_ops = 0;
1150+
} else if (flags & CEPH_OSD_FLAG_READ) {
1151+
num_req_ops = 0;
1152+
num_rep_ops = num_ops;
1153+
} else {
1154+
r = -EINVAL;
1155+
goto fail;
1156+
}
1157+
1158+
r = __ceph_osdc_alloc_messages(req, GFP_NOFS, num_req_ops,
1159+
num_rep_ops);
1160+
} else {
11471161
r = ceph_osdc_alloc_messages(req, GFP_NOFS);
1162+
}
11481163
if (r)
11491164
goto fail;
11501165

0 commit comments

Comments
 (0)