From patchwork Sun Mar 22 14:17:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6066791 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 831B19F399 for ; Sun, 22 Mar 2015 14:17:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A51EF20270 for ; Sun, 22 Mar 2015 14:17:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEE7A2026F for ; Sun, 22 Mar 2015 14:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751768AbbCVOR3 (ORCPT ); Sun, 22 Mar 2015 10:17:29 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:33941 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751769AbbCVOR2 (ORCPT ); Sun, 22 Mar 2015 10:17:28 -0400 Received: by pacwe9 with SMTP id we9so162868404pac.1 for ; Sun, 22 Mar 2015 07:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=aeuBsXkOfxgEfaxw5Lw6cCJYZ9QGaYz8K/4kPFBkG7k=; b=R4sq1XVppbHqGCkXaWDta2uZoc/OGDW0aq4C06YAZKB2btgbAkLJvh59bFhacz0Ffd AYkzX6iHWWWPp3NV2q/bL3TVbqZINUBe55Om8bT6wuyont3SiXN3ozJ7kjFYqsULQz5I hrjG0Ew7V60sLOln1AYklnyV/P2yeakhC+ByjItSowlmCXSfXr6f6Ga/uh8gOr+c0E/d x+ZF/wwVXWI6+qGOpYrfIVhlHnaq/4FT2YeCBCz7SULysF85LN3EZWe1tByJchqBieFN sHLEaW8dXx/TT3f++eFY6lOMUojXMzaLMxACuzABAdTJrYm27Cq8djwe9Zipuf5qYcAA teAg== X-Received: by 10.66.129.198 with SMTP id ny6mr173563276pab.67.1427033848101; Sun, 22 Mar 2015 07:17:28 -0700 (PDT) Received: from [192.168.99.7] ([104.143.41.80]) by mx.google.com with ESMTPSA id tg14sm14193938pac.15.2015.03.22.07.17.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Mar 2015 07:17:27 -0700 (PDT) Message-ID: <550ECEF0.6030505@gmail.com> Date: Sun, 22 Mar 2015 22:17:20 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "J. Bruce Fields" CC: Christoph Hellwig , Linux NFS Mailing List Subject: [PATCH] NFSD: Fix bad update of layout in nfsd4_return_file_layout Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With return layout as, (seg is return layout, lo is record layout) seg->offset <= lo->offset and layout_end(seg) < layout_end(lo), nfsd should update lo's offset to seg's end, and, seg->offset > lo->offset and layout_end(seg) >= layout_end(lo), nfsd should update lo's end to seg's offset. Fixes: 9cf514ccfa ("nfsd: implement pNFS operations") Signed-off-by: Kinglong Mee Reviewed-by: Christoph Hellwig --- fs/nfsd/nfs4layouts.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c index 6964613..80e236b 100644 --- a/fs/nfsd/nfs4layouts.c +++ b/fs/nfsd/nfs4layouts.c @@ -440,15 +440,14 @@ nfsd4_return_file_layout(struct nfs4_layout *lp, struct nfsd4_layout_seg *seg, list_move_tail(&lp->lo_perstate, reaplist); return; } - end = seg->offset; + lo->offset = layout_end(seg); } else { /* retain the whole layout segment on a split. */ if (layout_end(seg) < end) { dprintk("%s: split not supported\n", __func__); return; } - - lo->offset = layout_end(seg); + end = seg->offset; } layout_update_len(lo, end);