diff mbox

[21/38] SQUASHME: pnfsd: return bool from merge_layout and fix not found path

Message ID 1368240228-32538-1-git-send-email-bhalevy@tonian.com (mailing list archive)
State New, archived
Headers show

Commit Message

Benny Halevy May 11, 2013, 2:43 a.m. UTC
This also fixes the false return when no layout is found
(previously a non NULL pointer was returned)

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 fs/nfsd/nfs4pnfsd.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c
index 0bde7b7..ff688cb 100644
--- a/fs/nfsd/nfs4pnfsd.c
+++ b/fs/nfsd/nfs4pnfsd.c
@@ -578,7 +578,7 @@  struct super_block *
 /*
  * are two octet ranges overlapping or adjacent?
  */
-static int
+static bool
 lo_seg_mergeable(struct nfsd4_layout_seg *l1, struct nfsd4_layout_seg *l2)
 {
 	u64 start1 = l1->offset;
@@ -615,25 +615,26 @@  struct super_block *
 		      lo_end : lo_end - lo_start;
 }
 
-static struct nfs4_layout *
+static bool
 merge_layout(struct nfs4_file *fp,
 	     struct nfs4_client *clp,
 	     struct nfsd4_layout_seg *seg)
 {
-	struct nfs4_layout *lp = NULL;
+	bool ret = false;
+	struct nfs4_layout *lp;
 
 	spin_lock(&layout_lock);
 	list_for_each_entry (lp, &fp->fi_layouts, lo_perfile)
 		if (lp->lo_seg.layout_type == seg->layout_type &&
 		    lp->lo_seg.clientid == seg->clientid &&
 		    lp->lo_seg.iomode == seg->iomode &&
-		    lo_seg_mergeable(&lp->lo_seg, seg)) {
+		    (ret = lo_seg_mergeable(&lp->lo_seg, seg))) {
 			extend_layout(&lp->lo_seg, seg);
 			break;
 		}
 	spin_unlock(&layout_lock);
 
-	return lp;
+	return ret;
 }
 
 __be32