From patchwork Thu Jun 16 08:38:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 9180035 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A14660776 for ; Thu, 16 Jun 2016 08:38:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DD502835B for ; Thu, 16 Jun 2016 08:38:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12B7028386; Thu, 16 Jun 2016 08:38:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B12FD2835B for ; Thu, 16 Jun 2016 08:38:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753966AbcFPIiW (ORCPT ); Thu, 16 Jun 2016 04:38:22 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:50777 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751640AbcFPIiS (ORCPT ); Thu, 16 Jun 2016 04:38:18 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id u5G8c8Al007920; Thu, 16 Jun 2016 10:38:08 +0200 Date: Thu, 16 Jun 2016 10:38:08 +0200 From: Willy Tarreau To: Al Viro Cc: Linus Torvalds , Andy Lutomirski , Andy Lutomirski , Linux FS Devel , Stephen Rothwell , Andrew Morton , stable Subject: Re: [PATCH v2 1/2] fs: Improve and simplify copy_mount_options Message-ID: <20160616083807.GB7409@1wt.eu> References: <20160615235047.GA14480@ZenIV.linux.org.uk> <20160616054525.GA6803@1wt.eu> <20160616065738.GA7154@1wt.eu> <20160616070821.GB14480@ZenIV.linux.org.uk> <20160616072557.GA7336@1wt.eu> <20160616080229.GC14480@ZenIV.linux.org.uk> <20160616082038.GA7409@1wt.eu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160616082038.GA7409@1wt.eu> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Jun 16, 2016 at 10:20:38AM +0200, Willy Tarreau wrote: > However if the initial point was to avoid reading extra > pages most of the time, we could possibly consider that the string > copy is an optimization for the case where we have the information > available. Thus if !fstype || !(type->fs_flags & FS_BINARY_MOUNTDATA) > then we use copy_mount_options() otherwise we use copy_mount_string(). > It will only leave the full page copy for mount --bind or -o remount > then. For example like this (not compile-tested either) : --- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/compat.c b/fs/compat.c index be6e48b..6407d40 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -795,18 +795,26 @@ COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name, void *options; char *kernel_dev; int retval; + bool use_str = false; + struct file_system_type *fstype; kernel_type = copy_mount_string(type); retval = PTR_ERR(kernel_type); if (IS_ERR(kernel_type)) goto out; + if (kernel_type && (fstype = get_fs_type(kernel_type)) { + if (!(fstype->fs_flags & FS_BINARY_MOUNTDATA)) + use_str = true; + put_filesystem(fstype); + } + kernel_dev = copy_mount_string(dev_name); retval = PTR_ERR(kernel_dev); if (IS_ERR(kernel_dev)) goto out1; - options = copy_mount_options(data); + options = use_str ? copy_mount_string(data) : copy_mount_options(data); retval = PTR_ERR(options); if (IS_ERR(options)) goto out2; diff --git a/fs/namespace.c b/fs/namespace.c index 4fb1691..f14089d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2906,18 +2906,26 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, char *kernel_type; char *kernel_dev; void *options; + bool use_str = false; + struct file_system_type *fstype; kernel_type = copy_mount_string(type); ret = PTR_ERR(kernel_type); if (IS_ERR(kernel_type)) goto out_type; + if (kernel_type && (fstype = get_fs_type(kernel_type)) { + if (!(fstype->fs_flags & FS_BINARY_MOUNTDATA)) + use_str = true; + put_filesystem(fstype); + } + kernel_dev = copy_mount_string(dev_name); ret = PTR_ERR(kernel_dev); if (IS_ERR(kernel_dev)) goto out_dev; - options = copy_mount_options(data); + options = use_str ? copy_mount_string(data) : copy_mount_options(data); ret = PTR_ERR(options); if (IS_ERR(options)) goto out_data;