From patchwork Tue Aug 18 07:20:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 7028761 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4DCA2C05AD for ; Tue, 18 Aug 2015 07:20:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F9E3205DB for ; Tue, 18 Aug 2015 07:20:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5900F20788 for ; Tue, 18 Aug 2015 07:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751310AbbHRHUp (ORCPT ); Tue, 18 Aug 2015 03:20:45 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:35292 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750962AbbHRHUo (ORCPT ); Tue, 18 Aug 2015 03:20:44 -0400 Received: by pdob1 with SMTP id b1so9526106pdo.2; Tue, 18 Aug 2015 00:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=Pg385EDOxJZJipA/fljwblPkS29pwQTq+ztovtiTEUk=; b=MJuBj1tYK5J0agxy0bCHbmPuFFpDe86LmkTbE6fQLA31L529IH08p2cHqSg06fLHSk Vx8qohwfyV7AkLSrTBv6G3OzPsRvkJ/ABwJWkBlAHjmNT/7iyVyYU8ygPolpRnUzVGjm IrRhDrF5m/v2nvElfG08L7Zt3CA0bdQE1IJk+H2Xm5c7oYoqipc08RFhv4Sqa+IzPk6v MIK9shUGLP8oaPlmk8LWKQSTR98+A/Qn0puHXQoImAs4MXnyMZGZ7xUY48+hjL7IsIZH Vvh5ZxdwDx0hR981GQ6gb3/W/Dzd2T/el07tCsynlulp1Cl1npeCh68pm+cWaPESrxaM vAOA== X-Received: by 10.70.96.40 with SMTP id dp8mr10344894pdb.109.1439882444259; Tue, 18 Aug 2015 00:20:44 -0700 (PDT) Received: from [192.168.99.18] ([104.143.41.79]) by smtp.googlemail.com with ESMTPSA id mi6sm16984208pdb.1.2015.08.18.00.20.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2015 00:20:43 -0700 (PDT) Subject: [PATCH 3/6 v9] path: New helpers path_get_pin/path_put_unpin for path pin To: "J. Bruce Fields" , Al Viro References: <55D2DBF6.3010406@gmail.com> Cc: "linux-nfs@vger.kernel.org" , linux-fsdevel@vger.kernel.org, NeilBrown , Trond Myklebust , kinglongmee@gmail.com From: Kinglong Mee Message-ID: <55D2DCBF.3070106@gmail.com> Date: Tue, 18 Aug 2015 15:20:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55D2DBF6.3010406@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.2 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=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 Two helpers for filesystem pining to vfsmnt, not mntget. v9, Update base on NeilBrown's new patch Signed-off-by: Kinglong Mee --- fs/namei.c | 26 ++++++++++++++++++++++++++ include/linux/path.h | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/fs/namei.c b/fs/namei.c index 1c2105e..4f95e16 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -492,6 +492,32 @@ void path_put(const struct path *path) } EXPORT_SYMBOL(path_put); +/** + * path_get_pin - get a reference to a path's dentry + * and pin to path's vfsmnt + * @path: path to get the reference to + * @p: the fs_pin pin to vfsmnt + */ +void path_get_pin(struct path *path, struct fs_pin *p) +{ + dget(path->dentry); + pin_insert_group(p, path->mnt, NULL); +} +EXPORT_SYMBOL(path_get_pin); + +/** + * path_put_unpin - put a reference to a path's dentry + * and remove pin to path's vfsmnt + * @path: path to put the reference to + * @p: the fs_pin removed from vfsmnt + */ +int path_put_unpin(struct path *path, struct fs_pin *p) +{ + dput(path->dentry); + return pin_remove(p); +} +EXPORT_SYMBOL(path_put_unpin); + #define EMBEDDED_LEVELS 2 struct nameidata { struct path path; diff --git a/include/linux/path.h b/include/linux/path.h index d137218..40d376a 100644 --- a/include/linux/path.h +++ b/include/linux/path.h @@ -3,6 +3,7 @@ struct dentry; struct vfsmount; +struct fs_pin; struct path { struct vfsmount *mnt; @@ -12,6 +13,9 @@ struct path { extern void path_get(const struct path *); extern void path_put(const struct path *); +extern void path_get_pin(struct path *, struct fs_pin *); +extern int path_put_unpin(struct path *, struct fs_pin *); + static inline int path_equal(const struct path *path1, const struct path *path2) { return path1->mnt == path2->mnt && path1->dentry == path2->dentry;