From patchwork Tue Aug 19 15:18:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 4744101 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 3C87E9F377 for ; Tue, 19 Aug 2014 15:20:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2617520154 for ; Tue, 19 Aug 2014 15:20:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70DAE20179 for ; Tue, 19 Aug 2014 15:20:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753759AbaHSPT1 (ORCPT ); Tue, 19 Aug 2014 11:19:27 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:57748 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751808AbaHSPTZ (ORCPT ); Tue, 19 Aug 2014 11:19:25 -0400 Received: by mail-pa0-f53.google.com with SMTP id rd3so10227292pab.12 for ; Tue, 19 Aug 2014 08:19:20 -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 :references:in-reply-to:content-type:content-transfer-encoding; bh=GMOdWV+uKf1lBExWiuJ9Y50O6h80qNDkru72wNYKq+k=; b=gt7nP0ckdT/hdjJeVHPmKDx1TAUsP8TV8qSzJNLlgaSQOEIRbgKtfbD6cmG6oMpnIw y4JZGPeSqa4WDGy7cxrfsOceqlj9J8V7IngrSx/eOQ6x4uHoq5+n/oTFPuThQjKtU3Ma lxwhMZWHUa8sRuzX4JPbFoWXp9MijTlXxpRdHwV6NSc7UT5tY6IWPhxzKuiTYzuwArb3 +9Y82tfPu8mJcRf3pAawdS9sMgWmmBlWxtlF1fySEFUwTPDVVyz5vU18sQrOjA2bg0dZ SIE/LIrTH/cZ7LU3BRHl/KGBYccYxJq4sUMGA5Vttc2UXwz/Lj/pkhdnj4dINRPM5AGq YWjA== X-Received: by 10.70.35.166 with SMTP id i6mr43916741pdj.60.1408461560542; Tue, 19 Aug 2014 08:19:20 -0700 (PDT) Received: from [192.168.0.100] ([118.117.110.46]) by mx.google.com with ESMTPSA id ey10sm29822847pdb.50.2014.08.19.08.19.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Aug 2014 08:19:19 -0700 (PDT) Message-ID: <53F36AE2.7070507@gmail.com> Date: Tue, 19 Aug 2014 23:18:58 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Jeff Layton CC: "J. Bruce Fields" , Linux NFS Mailing List , Trond Myklebust , linux-fsdevel@vger.kernel.org, kinglongmee@gmail.com Subject: [PATCH 2/6 v4] locks: New ops in file_lock_operations for get/put owner References: <53BAAAC5.9000106@gmail.com> <53E22EA5.70708@gmail.com> <20140809065112.700e0ecc@tlielax.poochiereds.net> <53E791F1.40802@gmail.com> <53ED5093.6000308@gmail.com> In-Reply-To: <53ED5093.6000308@gmail.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=-7.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 NFSD or other lockmanager may increase the owner's reference, so adds two new options for copying and releasing owner. v4: rename lm_copy_owner/lm_release_owner to lm_get_owner/lm_put_owner Signed-off-by: Kinglong Mee Reviewed-by: Jeff Layton --- fs/locks.c | 12 ++++++++++-- include/linux/fs.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index cb66fb0..08342e0 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -230,8 +230,12 @@ void locks_release_private(struct file_lock *fl) fl->fl_ops->fl_release_private(fl); fl->fl_ops = NULL; } - fl->fl_lmops = NULL; + if (fl->fl_lmops) { + if (fl->fl_lmops->lm_put_owner) + fl->fl_lmops->lm_put_owner(fl); + fl->fl_lmops = NULL; + } } EXPORT_SYMBOL_GPL(locks_release_private); @@ -274,8 +278,12 @@ static void locks_copy_private(struct file_lock *new, struct file_lock *fl) fl->fl_ops->fl_copy_lock(new, fl); new->fl_ops = fl->fl_ops; } - if (fl->fl_lmops) + + if (fl->fl_lmops) { + if (fl->fl_lmops->lm_get_owner) + fl->fl_lmops->lm_get_owner(new, fl); new->fl_lmops = fl->fl_lmops; + } } /* diff --git a/include/linux/fs.h b/include/linux/fs.h index 908af4f..6829340 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -868,6 +868,8 @@ struct file_lock_operations { struct lock_manager_operations { int (*lm_compare_owner)(struct file_lock *, struct file_lock *); unsigned long (*lm_owner_key)(struct file_lock *); + void (*lm_get_owner)(struct file_lock *, struct file_lock *); + void (*lm_put_owner)(struct file_lock *); void (*lm_notify)(struct file_lock *); /* unblock callback */ int (*lm_grant)(struct file_lock *, int); void (*lm_break)(struct file_lock *);