Commit 6816282d authored by Sage Weil's avatar Sage Weil Committed by Alex Elder

ceph: propagate layout error on osd request creation

If we are creating an osd request and get an invalid layout, return
an EINVAL to the caller.  We switch up the return to have an error
code instead of NULL implying -ENOMEM.
Signed-off-by: default avatarSage Weil <sage@inktank.com>
Reviewed-by: default avatarAlex Elder <elder@inktank.com>
parent d63b77f4
...@@ -308,8 +308,8 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max) ...@@ -308,8 +308,8 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
NULL, 0, NULL, 0,
ci->i_truncate_seq, ci->i_truncate_size, ci->i_truncate_seq, ci->i_truncate_size,
NULL, false, 1, 0); NULL, false, 1, 0);
if (!req) if (IS_ERR(req))
return -ENOMEM; return PTR_ERR(req);
/* build page vector */ /* build page vector */
nr_pages = len >> PAGE_CACHE_SHIFT; nr_pages = len >> PAGE_CACHE_SHIFT;
...@@ -832,8 +832,8 @@ static int ceph_writepages_start(struct address_space *mapping, ...@@ -832,8 +832,8 @@ static int ceph_writepages_start(struct address_space *mapping,
ci->i_truncate_size, ci->i_truncate_size,
&inode->i_mtime, true, 1, 0); &inode->i_mtime, true, 1, 0);
if (!req) { if (IS_ERR(req)) {
rc = -ENOMEM; rc = PTR_ERR(req);
unlock_page(page); unlock_page(page);
break; break;
} }
......
...@@ -536,8 +536,8 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data, ...@@ -536,8 +536,8 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
do_sync, do_sync,
ci->i_truncate_seq, ci->i_truncate_size, ci->i_truncate_seq, ci->i_truncate_size,
&mtime, false, 2, page_align); &mtime, false, 2, page_align);
if (!req) if (IS_ERR(req))
return -ENOMEM; return PTR_ERR(req);
if (file->f_flags & O_DIRECT) { if (file->f_flags & O_DIRECT) {
pages = ceph_get_direct_page_vector(data, num_pages, false); pages = ceph_get_direct_page_vector(data, num_pages, false);
......
...@@ -464,6 +464,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, ...@@ -464,6 +464,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
{ {
struct ceph_osd_req_op ops[3]; struct ceph_osd_req_op ops[3];
struct ceph_osd_request *req; struct ceph_osd_request *req;
int r;
ops[0].op = opcode; ops[0].op = opcode;
ops[0].extent.truncate_seq = truncate_seq; ops[0].extent.truncate_seq = truncate_seq;
...@@ -482,10 +483,12 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, ...@@ -482,10 +483,12 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
use_mempool, use_mempool,
GFP_NOFS, NULL, NULL); GFP_NOFS, NULL, NULL);
if (!req) if (!req)
return NULL; return ERR_PTR(-ENOMEM);
/* calculate max write size */ /* calculate max write size */
calc_layout(osdc, vino, layout, off, plen, req, ops); r = calc_layout(osdc, vino, layout, off, plen, req, ops);
if (r < 0)
return ERR_PTR(r);
req->r_file_layout = *layout; /* keep a copy */ req->r_file_layout = *layout; /* keep a copy */
/* in case it differs from natural (file) alignment that /* in case it differs from natural (file) alignment that
...@@ -1928,8 +1931,8 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, ...@@ -1928,8 +1931,8 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
NULL, 0, truncate_seq, truncate_size, NULL, NULL, 0, truncate_seq, truncate_size, NULL,
false, 1, page_align); false, 1, page_align);
if (!req) if (IS_ERR(req))
return -ENOMEM; return PTR_ERR(req);
/* it may be a short read due to an object boundary */ /* it may be a short read due to an object boundary */
req->r_pages = pages; req->r_pages = pages;
...@@ -1971,8 +1974,8 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino, ...@@ -1971,8 +1974,8 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
snapc, do_sync, snapc, do_sync,
truncate_seq, truncate_size, mtime, truncate_seq, truncate_size, mtime,
nofail, 1, page_align); nofail, 1, page_align);
if (!req) if (IS_ERR(req))
return -ENOMEM; return PTR_ERR(req);
/* it may be a short write due to an object boundary */ /* it may be a short write due to an object boundary */
req->r_pages = pages; req->r_pages = pages;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment