From patchwork Wed Aug 20 09:54:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 4748671 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 C27199F3B4 for ; Wed, 20 Aug 2014 09:55:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2F3220109 for ; Wed, 20 Aug 2014 09:55:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1597820108 for ; Wed, 20 Aug 2014 09:55:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751292AbaHTJzP (ORCPT ); Wed, 20 Aug 2014 05:55:15 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:35990 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751075AbaHTJzO (ORCPT ); Wed, 20 Aug 2014 05:55:14 -0400 Received: by mail-pd0-f176.google.com with SMTP id y10so11644101pdj.21 for ; Wed, 20 Aug 2014 02:55:13 -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=8nOojFOyv6A2WlAleUUKOczVFkGc81R1nxALjFIRs9Q=; b=mYCEGeYnZl770RQllqjp8FvkzFDCC8EOMLNbig4yaoNl1zJ/ah4lElnBsHvZNGghVK 3ipit04lUZIyMBTWkGZIvOgAQ6lRxEtw2CKm5/L+5wGvpC0kKaitJvws6zIMc1uLFPSr xh3EkSpN1NavNzs5f8zodEmdoVsCBX/c5581NqetTt81zbQbhA+u9/2O+0qHB4pkGf55 Nezdn2fpRQlqd6ZrTTzdqbw7CfM5Jr7Cn2lHfQdUhlA+ZBS5aa52wLvu6ZjEvOjICtJW Qd9P3gXxht112P2hGq4oGYvjAEcXw8ZPOoqJw/VlbKVG/JI1HgDNxJrLNMEsUf58dbOM vrcA== X-Received: by 10.68.233.68 with SMTP id tu4mr51597725pbc.65.1408528513783; Wed, 20 Aug 2014 02:55:13 -0700 (PDT) Received: from [192.168.0.100] ([118.117.110.46]) by mx.google.com with ESMTPSA id aa4sm21879216pbc.22.2014.08.20.02.55.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Aug 2014 02:55:12 -0700 (PDT) Message-ID: <53F4706C.2080004@gmail.com> Date: Wed, 20 Aug 2014 17:54:52 +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 3/6 v5] 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> <53F36CB5.2030707@gmail.com> In-Reply-To: <53F36CB5.2030707@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. v5: change order from 2/6 to 3/6 v4: rename lm_copy_owner/lm_release_owner to lm_get_owner/lm_put_owner Reviewed-by: Jeff Layton Signed-off-by: Kinglong Mee --- 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 49ce390..c376561 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 5ab86f4..3b07ce2 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 *);