aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2012-09-25 00:01:02 -0400
committerAlex Elder <elder@inktank.com>2012-10-01 18:20:00 -0400
commit6816282dab3a72efe8c0d182c1bc2960d87f4322 (patch)
treec36cea753185ad22b073d41a1e5e5dbe56a928a1
parentd63b77f4c552cc3a20506871046ab0fcbc332609 (diff)
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: Sage Weil <sage@inktank.com> Reviewed-by: Alex Elder <elder@inktank.com>
-rw-r--r--fs/ceph/addr.c8
-rw-r--r--fs/ceph/file.c4
-rw-r--r--net/ceph/osd_client.c15
3 files changed, 15 insertions, 12 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 452e71a1b75..4469b63c9b7 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -308,8 +308,8 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
308 NULL, 0, 308 NULL, 0,
309 ci->i_truncate_seq, ci->i_truncate_size, 309 ci->i_truncate_seq, ci->i_truncate_size,
310 NULL, false, 1, 0); 310 NULL, false, 1, 0);
311 if (!req) 311 if (IS_ERR(req))
312 return -ENOMEM; 312 return PTR_ERR(req);
313 313
314 /* build page vector */ 314 /* build page vector */
315 nr_pages = len >> PAGE_CACHE_SHIFT; 315 nr_pages = len >> PAGE_CACHE_SHIFT;
@@ -832,8 +832,8 @@ get_more_pages:
832 ci->i_truncate_size, 832 ci->i_truncate_size,
833 &inode->i_mtime, true, 1, 0); 833 &inode->i_mtime, true, 1, 0);
834 834
835 if (!req) { 835 if (IS_ERR(req)) {
836 rc = -ENOMEM; 836 rc = PTR_ERR(req);
837 unlock_page(page); 837 unlock_page(page);
838 break; 838 break;
839 } 839 }
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index ecebbc09bfc..5840d2aaed1 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -536,8 +536,8 @@ more:
536 do_sync, 536 do_sync,
537 ci->i_truncate_seq, ci->i_truncate_size, 537 ci->i_truncate_seq, ci->i_truncate_size,
538 &mtime, false, 2, page_align); 538 &mtime, false, 2, page_align);
539 if (!req) 539 if (IS_ERR(req))
540 return -ENOMEM; 540 return PTR_ERR(req);
541 541
542 if (file->f_flags & O_DIRECT) { 542 if (file->f_flags & O_DIRECT) {
543 pages = ceph_get_direct_page_vector(data, num_pages, false); 543 pages = ceph_get_direct_page_vector(data, num_pages, false);
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index f7b56e23988..ccbdfbba9e5 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -464,6 +464,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
464{ 464{
465 struct ceph_osd_req_op ops[3]; 465 struct ceph_osd_req_op ops[3];
466 struct ceph_osd_request *req; 466 struct ceph_osd_request *req;
467 int r;
467 468
468 ops[0].op = opcode; 469 ops[0].op = opcode;
469 ops[0].extent.truncate_seq = truncate_seq; 470 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 use_mempool, 483 use_mempool,
483 GFP_NOFS, NULL, NULL); 484 GFP_NOFS, NULL, NULL);
484 if (!req) 485 if (!req)
485 return NULL; 486 return ERR_PTR(-ENOMEM);
486 487
487 /* calculate max write size */ 488 /* calculate max write size */
488 calc_layout(osdc, vino, layout, off, plen, req, ops); 489 r = calc_layout(osdc, vino, layout, off, plen, req, ops);
490 if (r < 0)
491 return ERR_PTR(r);
489 req->r_file_layout = *layout; /* keep a copy */ 492 req->r_file_layout = *layout; /* keep a copy */
490 493
491 /* in case it differs from natural (file) alignment that 494 /* in case it differs from natural (file) alignment that
@@ -1928,8 +1931,8 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
1928 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, 1931 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
1929 NULL, 0, truncate_seq, truncate_size, NULL, 1932 NULL, 0, truncate_seq, truncate_size, NULL,
1930 false, 1, page_align); 1933 false, 1, page_align);
1931 if (!req) 1934 if (IS_ERR(req))
1932 return -ENOMEM; 1935 return PTR_ERR(req);
1933 1936
1934 /* it may be a short read due to an object boundary */ 1937 /* it may be a short read due to an object boundary */
1935 req->r_pages = pages; 1938 req->r_pages = pages;
@@ -1971,8 +1974,8 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
1971 snapc, do_sync, 1974 snapc, do_sync,
1972 truncate_seq, truncate_size, mtime, 1975 truncate_seq, truncate_size, mtime,
1973 nofail, 1, page_align); 1976 nofail, 1, page_align);
1974 if (!req) 1977 if (IS_ERR(req))
1975 return -ENOMEM; 1978 return PTR_ERR(req);
1976 1979
1977 /* it may be a short write due to an object boundary */ 1980 /* it may be a short write due to an object boundary */
1978 req->r_pages = pages; 1981 req->r_pages = pages;