From patchwork Thu Sep 4 12:38:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4845061 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5B0139F390 for ; Thu, 4 Sep 2014 12:41:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4165C20256 for ; Thu, 4 Sep 2014 12:41:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01DB120120 for ; Thu, 4 Sep 2014 12:41:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753183AbaIDMjS (ORCPT ); Thu, 4 Sep 2014 08:39:18 -0400 Received: from mail-qc0-f171.google.com ([209.85.216.171]:60193 "EHLO mail-qc0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752825AbaIDMjM (ORCPT ); Thu, 4 Sep 2014 08:39:12 -0400 Received: by mail-qc0-f171.google.com with SMTP id x3so10152490qcv.2 for ; Thu, 04 Sep 2014 05:39:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=z1WCPocsoF3tJ2krDIcN5Nmcxi6pR1oRNa+MyDMk8lw=; b=BbDkRy/SxlAFa6wT/Z+EF6H9/1f9FpcFlA+C6frjbg2OHhN4HXFQgZYlQSTohxqgUf pF/XX8i448YmcMwjxov+DjfQ4V68FLN3BUY5RPE1oCR/GebhA2zz/WR0D80MdZGMtvqb seH/hGVt7IqiGxe2XMIoT0xj0FdDQdCFR6enRRjDppyrpCO6B7QkHhNH1ufPUPd+Krvg BWWmvdTpw36RSalrXerpd9bT9XCREdLjNluv8npoau9X4oO0sEWBsxKnpF+mccQcwUbG 47tvF1nUYSy9QprajQmiRDvSp1V2ckfmd3v6WYJdjePrMDRP4Tuh/3tC0FcwuJvsUXLi 3A2w== X-Gm-Message-State: ALoCoQnIgFfbDGSc4cvvD5Y1bbOdYjJcRpRR2JnlnCPkgJLX7EjTpgq34fXuUTv7SiMwsoEQKC2R X-Received: by 10.229.212.194 with SMTP id gt2mr6859160qcb.6.1409834352008; Thu, 04 Sep 2014 05:39:12 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id t5sm19186512qat.24.2014.09.04.05.39.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Sep 2014 05:39:11 -0700 (PDT) From: Jeff Layton To: linux-fsdevel@vger.kernel.org Cc: linux-nfs@vger.kernel.org, Christoph Hellwig , "J. Bruce Fields" , linux-kernel@vger.kernel.org Subject: [PATCH v2 10/17] locks: move i_lock acquisition into generic_*_lease handlers Date: Thu, 4 Sep 2014 08:38:36 -0400 Message-Id: <1409834323-7171-11-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1409834323-7171-1-git-send-email-jlayton@primarydata.com> References: <1409834323-7171-1-git-send-email-jlayton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Now that we have a saner internal API for managing leases, we no longer need to mandate that the inode->i_lock be held over most of the lease code. Push it down into generic_add_lease and generic_delete_lease. Signed-off-by: Jeff Layton Reviewed-by: Christoph Hellwig --- fs/locks.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index a5ed4a1f73ca..5bc61091263f 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1330,6 +1330,8 @@ static void time_out_leases(struct inode *inode) struct file_lock **before; struct file_lock *fl; + lockdep_assert_held(&inode->i_lock); + before = &inode->i_flock; while ((fl = *before) && IS_LEASE(fl) && lease_breaking(fl)) { trace_time_out_leases(inode, fl); @@ -1590,6 +1592,8 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr return -EINVAL; } + spin_lock(&inode->i_lock); + time_out_leases(inode); error = check_conflicting_open(dentry, arg); if (error) goto out; @@ -1655,6 +1659,7 @@ out_setup: if (lease->fl_lmops->lm_setup) lease->fl_lmops->lm_setup(lease, priv); out: + spin_unlock(&inode->i_lock); if (is_deleg) mutex_unlock(&inode->i_mutex); if (!error && !my_before) @@ -1672,6 +1677,7 @@ static int generic_delete_lease(struct file *filp) struct dentry *dentry = filp->f_path.dentry; struct inode *inode = dentry->d_inode; + spin_lock(&inode->i_lock); for (before = &inode->i_flock; ((fl = *before) != NULL) && IS_LEASE(fl); before = &fl->fl_next) { @@ -1681,6 +1687,7 @@ static int generic_delete_lease(struct file *filp) trace_generic_delete_lease(inode, fl); if (fl) error = fl->fl_lmops->lm_change(before, F_UNLCK); + spin_unlock(&inode->i_lock); return error; } @@ -1694,8 +1701,6 @@ static int generic_delete_lease(struct file *filp) * * The (input) flp->fl_lmops->lm_break function is required * by break_lease(). - * - * Called with inode->i_lock held. */ int generic_setlease(struct file *filp, long arg, struct file_lock **flp, void **priv) @@ -1712,8 +1717,6 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp, if (error) return error; - time_out_leases(inode); - switch (arg) { case F_UNLCK: return generic_delete_lease(filp); @@ -1750,16 +1753,10 @@ EXPORT_SYMBOL(generic_setlease); int vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv) { - struct inode *inode = file_inode(filp); - int error; - - spin_lock(&inode->i_lock); if (filp->f_op->setlease) - error = filp->f_op->setlease(filp, arg, lease, priv); + return filp->f_op->setlease(filp, arg, lease, priv); else - error = generic_setlease(filp, arg, lease, priv); - spin_unlock(&inode->i_lock); - return error; + return generic_setlease(filp, arg, lease, priv); } EXPORT_SYMBOL_GPL(vfs_setlease);