From patchwork Wed Oct 3 00:18:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 1540001 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B9B28DFFAD for ; Wed, 3 Oct 2012 00:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932864Ab2JCAS3 (ORCPT ); Tue, 2 Oct 2012 20:18:29 -0400 Received: from mx2.netapp.com ([216.240.18.37]:43561 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932885Ab2JCAS1 (ORCPT ); Tue, 2 Oct 2012 20:18:27 -0400 X-IronPort-AV: E=Sophos;i="4.80,525,1344236400"; d="scan'208";a="696730517" Received: from smtp1.corp.netapp.com ([10.57.156.124]) by mx2-out.netapp.com with ESMTP; 02 Oct 2012 17:18:26 -0700 Received: from lade.trondhjem.org.localdomain ([10.55.16.63]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id q930IPk2007813; Tue, 2 Oct 2012 17:18:26 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 4/5] NFSv4.1: Deal with wraparound when updating the layout "barrier" seqid Date: Tue, 2 Oct 2012 17:18:24 -0700 Message-Id: <1349223505-59248-4-git-send-email-Trond.Myklebust@netapp.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1349223505-59248-3-git-send-email-Trond.Myklebust@netapp.com> References: <1349223505-59248-1-git-send-email-Trond.Myklebust@netapp.com> <1349223505-59248-2-git-send-email-Trond.Myklebust@netapp.com> <1349223505-59248-3-git-send-email-Trond.Myklebust@netapp.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org ...and fix a bug in pnfs_set_layout_stateid. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index f1387e8..de82725 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -572,7 +572,7 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, if (update_barrier) { u32 new_barrier = be32_to_cpu(new->seqid); - if ((int)(new_barrier - lo->plh_barrier)) + if (pnfs_seqid_is_newer(new_barrier, lo->plh_barrier)) lo->plh_barrier = new_barrier; } else { /* Because of wraparound, we want to keep the barrier @@ -593,9 +593,12 @@ static bool pnfs_layoutgets_blocked(struct pnfs_layout_hdr *lo, nfs4_stateid *stateid, int lget) { - if ((stateid) && - (int)(lo->plh_barrier - be32_to_cpu(stateid->seqid)) >= 0) - return true; + if (stateid != NULL) { + u32 seqid = be32_to_cpu(stateid->seqid); + + if (!pnfs_seqid_is_newer(seqid, lo->plh_barrier)) + return true; + } return lo->plh_block_lgets || test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags) || (list_empty(&lo->plh_segs) &&