linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>, Thomas Meyer <thomas@m3y3r.de>
Cc: David Miller <davem@davemloft.net>,
	mjt@tls.msk.ru, linux-kernel@vger.kernel.org,
	autofs@vger.kernel.org, raven@themaw.net, stable@kernel.org
Subject: Re: [PATCH v2] Introduce a version6 of autofs interface, to fix design error.
Date: Sat, 28 Apr 2012 09:10:17 -0700	[thread overview]
Message-ID: <CA+55aFzdEcfXVXXqCumVJo=9+fK+1HvH6L4qY03HfTTvCs1Fwg@mail.gmail.com> (raw)
In-Reply-To: <CA+55aFxq4TunFa8mqJk5MHfvvFSg7Dr54acW7Cnqc5amOPdqrg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 658 bytes --]

On Fri, Apr 27, 2012 at 4:27 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> The attached patch implements that, and makes autofs automatically set
> the O_DIRECT flag.

Ok, since the packetized pipe approach makes the "compat" games in
autofs unnecessary (autofs can just always do the bigger write), I
have now reverted the commit that started this issue in my tree (and
marked it for stable). So automount should work again.

However, I would still like to know if systemd works with the attached
patch (it's pretty much the same patch as before, but the revert made
for some changes in the autofs code).

Thomas?

                    Linus

[-- Attachment #2: patch.diff --]
[-- Type: application/octet-stream, Size: 4286 bytes --]

 fs/autofs4/autofs_i.h  |   11 +++++++++++
 fs/autofs4/dev-ioctl.c |    2 +-
 fs/autofs4/inode.c     |    2 +-
 fs/autofs4/waitq.c     |    2 +-
 fs/pipe.c              |   17 +++++++++++------
 5 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index d8d8e7ba6a1e..5817343bad32 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -269,6 +269,17 @@ int autofs4_fill_super(struct super_block *, void *, int);
 struct autofs_info *autofs4_new_ino(struct autofs_sb_info *);
 void autofs4_clean_ino(struct autofs_info *);
 
+static inline int autofs_prepare_pipe(struct file *pipe)
+{
+	if (!pipe->f_op || !pipe->f_op->write)
+		return -EINVAL;
+	if (!pipe->f_dentry->d_inode->i_pipe)
+		return -EINVAL;
+	/* We want a packet pipe */
+	pipe->f_flags |= O_DIRECT;
+	return 0;
+}
+
 /* Queue management functions */
 
 int autofs4_wait(struct autofs_sb_info *,struct dentry *, enum autofs_notify);
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 3dfd615afb6b..aa9103f8f01b 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -376,7 +376,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
 			err = -EBADF;
 			goto out;
 		}
-		if (!pipe->f_op || !pipe->f_op->write) {
+		if (autofs_prepare_pipe(pipe) < 0) {
 			err = -EPIPE;
 			fput(pipe);
 			goto out;
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 14c7bc02349e..6e488ebe7784 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -290,7 +290,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
 		printk("autofs: could not open pipe file descriptor\n");
 		goto fail_dput;
 	}
-	if (!pipe->f_op || !pipe->f_op->write)
+	if (autofs_prepare_pipe(pipe) < 0)
 		goto fail_fput;
 	sbi->pipe = pipe;
 	sbi->pipefd = pipefd;
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index da8876d38a7b..f624cd0ff84d 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -91,7 +91,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
 
 	return (bytes > 0);
 }
-	
+
 static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
 				 struct autofs_wait_queue *wq,
 				 int type)
diff --git a/fs/pipe.c b/fs/pipe.c
index 25feaa3faac0..c65051eb6893 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -346,6 +346,11 @@ static const struct pipe_buf_operations anon_pipe_buf_ops = {
 	.get = generic_pipe_buf_get,
 };
 
+static inline int is_packetized(struct file *file)
+{
+	return (file->f_flags & O_DIRECT) != 0;
+}
+
 static ssize_t
 pipe_read(struct kiocb *iocb, const struct iovec *_iov,
 	   unsigned long nr_segs, loff_t pos)
@@ -407,7 +412,7 @@ redo:
 			ret += chars;
 			buf->offset += chars;
 			buf->len -= chars;
-			if (!buf->len) {
+			if (!buf->len || is_packetized(filp)) {
 				buf->ops = NULL;
 				ops->release(pipe, buf);
 				curbuf = (curbuf + 1) & (pipe->buffers - 1);
@@ -416,7 +421,7 @@ redo:
 				do_wakeup = 1;
 			}
 			total_len -= chars;
-			if (!total_len)
+			if (!total_len || is_packetized(filp))
 				break;	/* common path: read succeeded */
 		}
 		if (bufs)	/* More to do? */
@@ -490,7 +495,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
 
 	/* We try to merge small writes */
 	chars = total_len & (PAGE_SIZE-1); /* size of the last buffer */
-	if (pipe->nrbufs && chars != 0) {
+	if (!is_packetized(filp) && pipe->nrbufs && chars != 0) {
 		int lastbuf = (pipe->curbuf + pipe->nrbufs - 1) &
 							(pipe->buffers - 1);
 		struct pipe_buffer *buf = pipe->bufs + lastbuf;
@@ -1013,7 +1018,7 @@ struct file *create_write_pipe(int flags)
 		goto err_dentry;
 	f->f_mapping = inode->i_mapping;
 
-	f->f_flags = O_WRONLY | (flags & O_NONBLOCK);
+	f->f_flags = O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT));
 	f->f_version = 0;
 
 	return f;
@@ -1046,7 +1051,7 @@ struct file *create_read_pipe(struct file *wrf, int flags)
 		return ERR_PTR(-ENFILE);
 
 	path_get(&wrf->f_path);
-	f->f_flags = O_RDONLY | (flags & O_NONBLOCK);
+	f->f_flags = O_RDONLY | (flags & (O_NONBLOCK | O_DIRECT));
 
 	return f;
 }
@@ -1057,7 +1062,7 @@ int do_pipe_flags(int *fd, int flags)
 	int error;
 	int fdw, fdr;
 
-	if (flags & ~(O_CLOEXEC | O_NONBLOCK))
+	if (flags & ~(O_CLOEXEC | O_NONBLOCK | O_DIRECT))
 		return -EINVAL;
 
 	fw = create_write_pipe(flags);

  reply	other threads:[~2012-04-28 16:10 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 13:34 [PATCH v2] Introduce a version6 of autofs interface, to fix design error Michael Tokarev
2012-04-26 13:44 ` Michael Tokarev
2012-04-27  0:37 ` Linus Torvalds
2012-04-27  9:45   ` Michael Tokarev
2012-04-27 15:47     ` Mark Lord
2012-04-27 20:37       ` H. Peter Anvin
2012-04-28 22:20         ` Mark Lord
2012-04-27 16:22     ` David Miller
2012-04-27 17:10       ` Michael Tokarev
2012-04-27 17:28         ` David Miller
2012-04-27 18:19     ` Linus Torvalds
2012-04-27 18:34       ` David Miller
2012-04-27 18:42         ` Linus Torvalds
2012-04-27 18:55           ` Linus Torvalds
2012-04-27 19:14             ` David Miller
2012-04-27 19:16               ` David Miller
2012-04-27 19:19                 ` Linus Torvalds
2012-04-27 19:24                   ` David Miller
2012-04-27 19:56                     ` Linus Torvalds
2012-04-27 20:13                       ` Stef Bon
2012-04-27 20:29                       ` David Miller
2012-04-27 22:40                         ` Linus Torvalds
2012-04-27 20:43                       ` H. Peter Anvin
2012-04-27 22:42                         ` Linus Torvalds
2012-04-27 22:56                           ` H. Peter Anvin
2012-04-27 23:07                             ` Linus Torvalds
2012-04-28  0:03                               ` H. Peter Anvin
2012-04-28  0:17                                 ` Linus Torvalds
2012-04-27 22:42                       ` Alan Cox
2012-04-27 22:49                         ` Linus Torvalds
2012-04-27 23:27                         ` Linus Torvalds
2012-04-28 16:10                           ` Linus Torvalds [this message]
2012-04-29  6:37                             ` Michael Tokarev
2012-04-29  7:19                               ` Linus Torvalds
2012-04-29  7:45                                 ` Michael Tokarev
2012-04-29 18:29                                   ` Linus Torvalds
2012-04-29 19:09                                     ` Linus Torvalds
2012-04-29 19:53                                       ` Michael Tokarev
2012-04-29 20:53                                         ` Linus Torvalds
2012-04-30  8:41                                         ` Thomas Meyer
2012-04-28  1:56               ` Ian Kent
2012-04-27 19:08           ` David Miller
2012-04-27 20:45             ` H. Peter Anvin
2012-04-27 20:42       ` H. Peter Anvin

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='CA+55aFzdEcfXVXXqCumVJo=9+fK+1HvH6L4qY03HfTTvCs1Fwg@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=autofs@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjt@tls.msk.ru \
    --cc=raven@themaw.net \
    --cc=stable@kernel.org \
    --cc=thomas@m3y3r.de \
    /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;
as well as URLs for NNTP newsgroup(s).