From patchwork Thu Jun 25 14:21:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6675531 Return-Path: X-Original-To: patchwork-linux-nfs@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 1B316C05AC for ; Thu, 25 Jun 2015 14:21:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4880F206C0 for ; Thu, 25 Jun 2015 14:21:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B241206CB for ; Thu, 25 Jun 2015 14:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751648AbbFYOVt (ORCPT ); Thu, 25 Jun 2015 10:21:49 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:32839 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbbFYOVs (ORCPT ); Thu, 25 Jun 2015 10:21:48 -0400 Received: by pdjn11 with SMTP id n11so54543206pdj.0; Thu, 25 Jun 2015 07:21:47 -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=EmmJ2iBGX8gY9h6AQy8ckAOLEgLzyWxuRHdBbP/ofRU=; b=KAXCsiRn/eWyEkLQctsQfGJYd5+8cUCIfexs6Cj27SBXWxI8ZATvfIL+U2ILeOIPgJ MbJLM4SEdhcmb4LYnj0a7D9BijzmUiMnCGhWpBOM4VKQNmOyM2EHPuOVqYbpop9bh4Pd Sw+acSnSctZ2mJeYu/JJxlqARxv6iDrOhZIosEWyB4hwCPCrVzvR15TaLw7I7lxE9qyf J8ORPyQ6X8PybBjOB0jUIpkGqFpjUuF7VX4otrxYNooVDosMczHoHUtGmKVS1RJltq3D 8fq1INqxiDLb+VuQsQd+eIu8yvDuSeCakxdrXjn35stR+PzVvFif6rgBwYZobAngksq7 /eLA== X-Received: by 10.70.47.9 with SMTP id z9mr92379900pdm.69.1435242107685; Thu, 25 Jun 2015 07:21:47 -0700 (PDT) Received: from [192.168.99.10] ([104.143.41.79]) by mx.google.com with ESMTPSA id ho2sm30246908pbb.14.2015.06.25.07.21.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2015 07:21:46 -0700 (PDT) Message-ID: <558C0E6D.3000704@gmail.com> Date: Thu, 25 Jun 2015 22:21:33 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Al Viro , "J. Bruce Fields" , "linux-nfs@vger.kernel.org" , linux-fsdevel@vger.kernel.org CC: NeilBrown , Trond Myklebust , kinglongmee@gmail.com Subject: [PATCH 04/10 v6] fs: New helper legitimize_mntget() for getting a legitimize mnt References: <558C0D6A.9050104@gmail.com> In-Reply-To: <558C0D6A.9050104@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=-8.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=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 New helper legitimize_mntget for getting a mnt without setting MNT_SYNC_UMOUNT | MNT_UMOUNT | MNT_DOOMED, otherwise return NULL. v6, New one Signed-off-by: Kinglong Mee --- fs/namespace.c | 19 +++++++++++++++++++ include/linux/mount.h | 1 + 2 files changed, 20 insertions(+) diff --git a/fs/namespace.c b/fs/namespace.c index 1f4f9da..f31d165 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1142,6 +1142,25 @@ struct vfsmount *mntget(struct vfsmount *mnt) } EXPORT_SYMBOL(mntget); +struct vfsmount *legitimize_mntget(struct vfsmount *vfsmnt) +{ + struct mount *mnt; + + if (vfsmnt == NULL) + return NULL; + + read_seqlock_excl(&mount_lock); + mnt = real_mount(vfsmnt); + if (vfsmnt->mnt_flags & (MNT_SYNC_UMOUNT | MNT_UMOUNT | MNT_DOOMED)) + vfsmnt = NULL; + else + mnt_add_count(mnt, 1); + read_sequnlock_excl(&mount_lock); + + return vfsmnt; +} +EXPORT_SYMBOL(legitimize_mntget); + struct vfsmount *mnt_clone_internal(struct path *path) { struct mount *p; diff --git a/include/linux/mount.h b/include/linux/mount.h index f822c3c..8ae9dc0 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -79,6 +79,7 @@ extern void mnt_drop_write(struct vfsmount *mnt); extern void mnt_drop_write_file(struct file *file); extern void mntput(struct vfsmount *mnt); extern struct vfsmount *mntget(struct vfsmount *mnt); +extern struct vfsmount *legitimize_mntget(struct vfsmount *vfsmnt); extern struct vfsmount *mnt_clone_internal(struct path *path); extern int __mnt_is_readonly(struct vfsmount *mnt);