Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ceph: eliminate req->r_wait_for_completion from ceph_mds_request

...and instead just pass the wait function on the stack.

Make ceph_mdsc_wait_request non-static, and add an argument for wait for
completion. Then have ceph_lock_message call ceph_mdsc_submit_request,
and ceph_mdsc_wait_request and pass in the pointer to
ceph_lock_wait_for_completion.

While we're in there, rearrange some fields in ceph_mds_request, so we
save a total of 24 bytes per.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

authored by

Jeff Layton and committed by
Ilya Dryomov
9eaa7b79 083db6fd

+15 -13
+4 -4
fs/ceph/locks.c
··· 111 111 req->r_args.filelock_change.length = cpu_to_le64(length); 112 112 req->r_args.filelock_change.wait = wait; 113 113 114 - if (wait) 115 - req->r_wait_for_completion = ceph_lock_wait_for_completion; 116 - 117 - err = ceph_mdsc_do_request(mdsc, inode, req); 114 + err = ceph_mdsc_submit_request(mdsc, inode, req); 115 + if (!err) 116 + err = ceph_mdsc_wait_request(mdsc, req, wait ? 117 + ceph_lock_wait_for_completion : NULL); 118 118 if (!err && operation == CEPH_MDS_OP_GETFILELOCK) { 119 119 fl->fl_pid = -le64_to_cpu(req->r_reply_info.filelock_reply->pid); 120 120 if (CEPH_LOCK_SHARED == req->r_reply_info.filelock_reply->type)
+6 -5
fs/ceph/mds_client.c
··· 2946 2946 return err; 2947 2947 } 2948 2948 2949 - static int ceph_mdsc_wait_request(struct ceph_mds_client *mdsc, 2950 - struct ceph_mds_request *req) 2949 + int ceph_mdsc_wait_request(struct ceph_mds_client *mdsc, 2950 + struct ceph_mds_request *req, 2951 + ceph_mds_request_wait_callback_t wait_func) 2951 2952 { 2952 2953 int err; 2953 2954 2954 2955 /* wait */ 2955 2956 dout("do_request waiting\n"); 2956 - if (!req->r_timeout && req->r_wait_for_completion) { 2957 - err = req->r_wait_for_completion(mdsc, req); 2957 + if (wait_func) { 2958 + err = wait_func(mdsc, req); 2958 2959 } else { 2959 2960 long timeleft = wait_for_completion_killable_timeout( 2960 2961 &req->r_completion, ··· 3012 3011 /* issue */ 3013 3012 err = ceph_mdsc_submit_request(mdsc, dir, req); 3014 3013 if (!err) 3015 - err = ceph_mdsc_wait_request(mdsc, req); 3014 + err = ceph_mdsc_wait_request(mdsc, req, NULL); 3016 3015 dout("do_request %p done, result %d\n", req, err); 3017 3016 return err; 3018 3017 }
+5 -4
fs/ceph/mds_client.h
··· 274 274 275 275 union ceph_mds_request_args r_args; 276 276 int r_fmode; /* file mode, if expecting cap */ 277 - const struct cred *r_cred; 278 277 int r_request_release_offset; 278 + const struct cred *r_cred; 279 279 struct timespec64 r_stamp; 280 280 281 281 /* for choosing which mds to send this request to */ ··· 296 296 struct ceph_msg *r_reply; 297 297 struct ceph_mds_reply_info_parsed r_reply_info; 298 298 int r_err; 299 - 299 + u32 r_readdir_offset; 300 300 301 301 struct page *r_locked_page; 302 302 int r_dir_caps; 303 303 int r_num_caps; 304 - u32 r_readdir_offset; 305 304 306 305 unsigned long r_timeout; /* optional. jiffies, 0 is "wait forever" */ 307 306 unsigned long r_started; /* start time to measure timeout against */ ··· 328 329 struct completion r_completion; 329 330 struct completion r_safe_completion; 330 331 ceph_mds_request_callback_t r_callback; 331 - ceph_mds_request_wait_callback_t r_wait_for_completion; 332 332 struct list_head r_unsafe_item; /* per-session unsafe list item */ 333 333 334 334 long long r_dir_release_cnt; ··· 505 507 extern int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, 506 508 struct inode *dir, 507 509 struct ceph_mds_request *req); 510 + int ceph_mdsc_wait_request(struct ceph_mds_client *mdsc, 511 + struct ceph_mds_request *req, 512 + ceph_mds_request_wait_callback_t wait_func); 508 513 extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, 509 514 struct inode *dir, 510 515 struct ceph_mds_request *req);