]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ceph: propagate layout error on osd request creation
authorSage Weil <sage@inktank.com>
Tue, 25 Sep 2012 04:01:02 +0000 (21:01 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jan 2013 16:51:18 +0000 (08:51 -0800)
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>
(cherry picked from commit 6816282dab3a72efe8c0d182c1bc2960d87f4322)
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ceph/addr.c
fs/ceph/file.c
net/ceph/osd_client.c

index 32ee086c259b780fb19023fd89665ccdd9fe40d7..e009fde39cf6590625bf9f0f3bb964415cd955a4 100644 (file)
@@ -308,8 +308,8 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
                                    NULL, 0,
                                    ci->i_truncate_seq, ci->i_truncate_size,
                                    NULL, false, 1, 0);
-       if (!req)
-               return -ENOMEM;
+       if (IS_ERR(req))
+               return PTR_ERR(req);
 
        /* build page vector */
        nr_pages = len >> PAGE_CACHE_SHIFT;
@@ -831,8 +831,8 @@ get_more_pages:
                                            ci->i_truncate_size,
                                            &inode->i_mtime, true, 1, 0);
 
-                               if (!req) {
-                                       rc = -ENOMEM;
+                               if (IS_ERR(req)) {
+                                       rc = PTR_ERR(req);
                                        unlock_page(page);
                                        break;
                                }
index ed72428d9c75c80a6744ccd6a996b83c1a20d333..9ce3a4bd4d1c888c399e080581d6d98a3dc76140 100644 (file)
@@ -529,8 +529,8 @@ more:
                                    do_sync,
                                    ci->i_truncate_seq, ci->i_truncate_size,
                                    &mtime, false, 2, page_align);
-       if (!req)
-               return -ENOMEM;
+       if (IS_ERR(req))
+               return PTR_ERR(req);
 
        if (file->f_flags & O_DIRECT) {
                pages = ceph_get_direct_page_vector(data, num_pages, false);
index a79dbae3ea90be453015fac175039b50388a104b..37a9f1e61241be97142cb1c5d483e1d498383549 100644 (file)
@@ -461,6 +461,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
 {
        struct ceph_osd_req_op ops[3];
        struct ceph_osd_request *req;
+       int r;
 
        ops[0].op = opcode;
        ops[0].extent.truncate_seq = truncate_seq;
@@ -479,10 +480,12 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
                                         use_mempool,
                                         GFP_NOFS, NULL, NULL);
        if (!req)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        /* 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 */
 
        /* in case it differs from natural (file) alignment that
@@ -1925,8 +1928,8 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
                                    CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
                                    NULL, 0, truncate_seq, truncate_size, NULL,
                                    false, 1, page_align);
-       if (!req)
-               return -ENOMEM;
+       if (IS_ERR(req))
+               return PTR_ERR(req);
 
        /* it may be a short read due to an object boundary */
        req->r_pages = pages;
@@ -1968,8 +1971,8 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
                                    snapc, do_sync,
                                    truncate_seq, truncate_size, mtime,
                                    nofail, 1, page_align);
-       if (!req)
-               return -ENOMEM;
+       if (IS_ERR(req))
+               return PTR_ERR(req);
 
        /* it may be a short write due to an object boundary */
        req->r_pages = pages;