From: Willy Tarreau <w@1wt.eu>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirski <luto@amacapital.net>,
Andy Lutomirski <luto@kernel.org>,
Linux FS Devel <linux-fsdevel@vger.kernel.org>,
Stephen Rothwell <sfr@canb.auug.org.au>,
Andrew Morton <akpm@linux-foundation.org>,
stable <stable@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] fs: Improve and simplify copy_mount_options
Date: Thu, 16 Jun 2016 10:38:08 +0200 [thread overview]
Message-ID: <20160616083807.GB7409@1wt.eu> (raw)
In-Reply-To: <20160616082038.GA7409@1wt.eu>
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) :
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;
next prev parent reply other threads:[~2016-06-16 8:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1465871650.git.luto@kernel.org>
2016-06-14 2:36 ` [PATCH v2 1/2] fs: Improve and simplify copy_mount_options Andy Lutomirski
2016-06-15 23:50 ` Al Viro
2016-06-16 0:01 ` Andy Lutomirski
2016-06-16 0:42 ` Linus Torvalds
2016-06-16 5:45 ` Willy Tarreau
2016-06-16 5:59 ` Linus Torvalds
2016-06-16 6:57 ` Willy Tarreau
2016-06-16 7:02 ` Willy Tarreau
2016-06-16 7:08 ` Al Viro
2016-06-16 7:25 ` Willy Tarreau
2016-06-16 8:02 ` Al Viro
2016-06-16 8:20 ` Willy Tarreau
2016-06-16 8:38 ` Willy Tarreau [this message]
2016-06-17 3:12 ` Andy Lutomirski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160616083807.GB7409@1wt.eu \
--to=w@1wt.eu \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=luto@kernel.org \
--cc=sfr@canb.auug.org.au \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox