<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/fs/pipe.c, branch v3.4.19</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/fs/pipe.c?h=v3.4.19</id>
<link rel='self' href='https://git.amat.us/linux/atom/fs/pipe.c?h=v3.4.19'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2012-04-29T20:12:42Z</updated>
<entry>
<title>pipes: add a "packetized pipe" mode for writing</title>
<updated>2012-04-29T20:12:42Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-04-29T20:12:42Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=9883035ae7edef3ec62ad215611cb8e17d6a1a5d'/>
<id>urn:sha1:9883035ae7edef3ec62ad215611cb8e17d6a1a5d</id>
<content type='text'>
The actual internal pipe implementation is already really about
individual packets (called "pipe buffers"), and this simply exposes that
as a special packetized mode.

When we are in the packetized mode (marked by O_DIRECT as suggested by
Alan Cox), a write() on a pipe will not merge the new data with previous
writes, so each write will get a pipe buffer of its own.  The pipe
buffer is then marked with the PIPE_BUF_FLAG_PACKET flag, which in turn
will tell the reader side to break the read at that boundary (and throw
away any partial packet contents that do not fit in the read buffer).

End result: as long as you do writes less than PIPE_BUF in size (so that
the pipe doesn't have to split them up), you can now treat the pipe as a
packet interface, where each read() system call will read one packet at
a time.  You can just use a sufficiently big read buffer (PIPE_BUF is
sufficient, since bigger than that doesn't guarantee atomicity anyway),
and the return value of the read() will naturally give you the size of
the packet.

NOTE! We do not support zero-sized packets, and zero-sized reads and
writes to a pipe continue to be no-ops.  Also note that big packets will
currently be split at write time, but that the size at which that
happens is not really specified (except that it's bigger than PIPE_BUF).
Currently that limit is the system page size, but we might want to
explicitly support bigger packets some day.

The main user for this is going to be the autofs packet interface,
allowing us to stop having to care so deeply about exact packet sizes
(which have had bugs with 32/64-bit compatibility modes).  But user
space can create packetized pipes with "pipe2(fd, O_DIRECT)", which will
fail with an EINVAL on kernels that do not support this interface.

Tested-by: Michael Tokarev &lt;mjt@tls.msk.ru&gt;
Cc: Alan Cox &lt;alan@lxorguk.ukuu.org.uk&gt;
Cc: David Miller &lt;davem@davemloft.net&gt;
Cc: Ian Kent &lt;raven@themaw.net&gt;
Cc: Thomas Meyer &lt;thomas@m3y3r.de&gt;
Cc: stable@kernel.org  # needed for systemd/autofs interaction fix
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>magic.h: move some FS magic numbers into magic.h</title>
<updated>2012-03-23T23:58:31Z</updated>
<author>
<name>Muthu Kumar</name>
<email>muthu.lkml@gmail.com</email>
</author>
<published>2012-03-23T22:01:50Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=b502bd1152472dc1b98c60434f23c23b280c7b94'/>
<id>urn:sha1:b502bd1152472dc1b98c60434f23c23b280c7b94</id>
<content type='text'>
- Move open-coded filesystem magic numbers into magic.h

- Rearrange magic.h so that the filesystem-related constants are grouped
  together.

Signed-off-by: Muthukumar R &lt;muthur@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>fs: remove the second argument of k[un]map_atomic()</title>
<updated>2012-03-20T13:48:21Z</updated>
<author>
<name>Cong Wang</name>
<email>amwang@redhat.com</email>
</author>
<published>2011-11-25T15:14:27Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=e8e3c3d66fd9d1ee2250f68d778cc48c1346d228'/>
<id>urn:sha1:e8e3c3d66fd9d1ee2250f68d778cc48c1346d228</id>
<content type='text'>
Acked-by: Benjamin LaHaise &lt;bcrl@kvack.org&gt;
Signed-off-by: Cong Wang &lt;amwang@redhat.com&gt;
</content>
</entry>
<entry>
<title>pipe: fail cleanly when root tries F_SETPIPE_SZ with big size</title>
<updated>2012-01-13T04:13:04Z</updated>
<author>
<name>Sasha Levin</name>
<email>levinsasha928@gmail.com</email>
</author>
<published>2012-01-13T01:17:40Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=2ccd4f4d4737b37e21dd92c8c584c23cd87740a2'/>
<id>urn:sha1:2ccd4f4d4737b37e21dd92c8c584c23cd87740a2</id>
<content type='text'>
When a user with the CAP_SYS_RESOURCE cap tries to F_SETPIPE_SZ a pipe
with size bigger than kmalloc() can alloc it spits out an ugly warning:

  ------------[ cut here ]------------
  WARNING: at mm/page_alloc.c:2095 __alloc_pages_nodemask+0x5d3/0x7a0()
  Pid: 733, comm: a.out Not tainted 3.2.0-rc1+ #4
  Call Trace:
     warn_slowpath_common+0x75/0xb0
     warn_slowpath_null+0x15/0x20
     __alloc_pages_nodemask+0x5d3/0x7a0
     __get_free_pages+0x12/0x50
     __kmalloc+0x12b/0x150
     pipe_set_size+0x75/0x120
     pipe_fcntl+0xf8/0x140
     do_fcntl+0x2d4/0x410
     sys_fcntl+0x66/0xa0
     system_call_fastpath+0x16/0x1b
  ---[ end trace 432f702e6db7b5ee ]---

Instead, make kcalloc() handle the overflow case and fail quietly.

[akpm@linux-foundation.org: switch to sizeof(*bufs) for 80-column niceness]
Signed-off-by: Sasha Levin &lt;levinsasha928@gmail.com&gt;
Cc: Alexander Viro &lt;viro@zeniv.linux.org.uk&gt;
Acked-by: Pekka Enberg &lt;penberg@kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>vfs: pipe.c is really non-modular</title>
<updated>2012-01-04T03:52:41Z</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2011-12-19T01:17:41Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=84b92d39f98f669a3073168f88692782aec525a8'/>
<id>urn:sha1:84b92d39f98f669a3073168f88692782aec525a8</id>
<content type='text'>
... so no exitcalls there.  Not much would work if pipe(2) would stop
working, after all...

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>fs/pipe.c: add -&gt;statfs callback for pipefs</title>
<updated>2011-11-01T00:30:51Z</updated>
<author>
<name>Pavel Emelyanov</name>
<email>xemul@parallels.com</email>
</author>
<published>2011-11-01T00:10:04Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=d70ef97baf048412c395bb5d65791d8fe133a52b'/>
<id>urn:sha1:d70ef97baf048412c395bb5d65791d8fe133a52b</id>
<content type='text'>
Currently a statfs on a pipe's /proc/&lt;pid&gt;/fd/ link returns -ENOSYS.  Wire
pipfs up so that the statfs succeeds.

This is required by checkpoint-restart in the userspace to make it
possible to distinguish pipes from fifos.

When we dump information about task's open files we use the /proc/pid/fd
directoy's symlinks and the fact that opening any of them gives us exactly
the same dentry-&gt;inode pair as the original process has.  Now if a task
we're dumping has opened pipe and fifo we need to detect this and act
accordingly.  Knowing that an fd with type S_ISFIFO resides on a pipefs is
the most precise way.

Signed-off-by: Pavel Emelyanov &lt;xemul@parallels.com&gt;
Reviewed-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Serge Hallyn &lt;serge.hallyn@canonical.com&gt;
Signed-off-by: Cyrill Gorcunov &lt;gorcunov@openvz.org&gt;
Cc: Al Viro &lt;viro@ZenIV.linux.org.uk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>vfs: dont chain pipe/anon/socket on superblock s_inodes list</title>
<updated>2011-07-26T16:57:09Z</updated>
<author>
<name>Eric Dumazet</name>
<email>eric.dumazet@gmail.com</email>
</author>
<published>2011-07-26T09:36:34Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a209dfc7b0d94bd6fa94553c097836a2e6d0f0ba'/>
<id>urn:sha1:a209dfc7b0d94bd6fa94553c097836a2e6d0f0ba</id>
<content type='text'>
Workloads using pipes and sockets hit inode_sb_list_lock contention.

superblock s_inodes list is needed for quota, dirty, pagecache and
fsnotify management. pipe/anon/socket fs are clearly not candidates for
these.

Signed-off-by: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>VFS : mount lock scalability for internal mounts</title>
<updated>2011-07-24T14:08:32Z</updated>
<author>
<name>Tim Chen</name>
<email>tim.c.chen@linux.intel.com</email>
</author>
<published>2011-07-19T16:32:38Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=423e0ab086ad8b33626e45fa94ac7613146b7ffa'/>
<id>urn:sha1:423e0ab086ad8b33626e45fa94ac7613146b7ffa</id>
<content type='text'>
For a number of file systems that don't have a mount point (e.g. sockfs
and pipefs), they are not marked as long term. Therefore in
mntput_no_expire, all locks in vfs_mount lock are taken instead of just
local cpu's lock to aggregate reference counts when we release
reference to file objects.  In fact, only local lock need to have been
taken to update ref counts as these file systems are in no danger of
going away until we are ready to unregister them.

The attached patch marks file systems using kern_mount without
mount point as long term.  The contentions of vfs_mount lock
is now eliminated.  Before un-registering such file system,
kern_unmount should be called to remove the long term flag and
make the mount point ready to be freed.

Signed-off-by: Tim Chen &lt;tim.c.chen@linux.intel.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>Fix broken "pipe: use event aware wakeups" optimization</title>
<updated>2011-01-21T00:21:59Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2011-01-21T00:21:59Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=28e58ee8ce1f0e69c207f747b7b9054b071e328d'/>
<id>urn:sha1:28e58ee8ce1f0e69c207f747b7b9054b071e328d</id>
<content type='text'>
Commit e462c448fdc8 ("pipe: use event aware wakeups") optimized the pipe
event wakeup calls to avoid wakeups if the events do not match the
requested set.

However, the optimization was buggy, in that it didn't actually use the
correct sets for the events: when we make room for more data to be
written, the pipe poll() routine will return both the POLLOUT _and_
POLLWRNORM bits.  Similarly for read.

And most critically, when a pipe is released, that will potentially
result in POLLHUP|POLLERR (depending on whether it was the last reader
or writer), not just the regular POLLIN|POLLOUT.

This bug showed itself as a hung gnome-screensaver-dialog process, stuck
forever (or at least until it was poked by a signal or by being traced)
in a poll() system call.

Cc: Davide Libenzi &lt;davidel@xmailserver.org&gt;
Cc: David S. Miller &lt;davem@davemloft.net&gt;
Cc: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>sanitize vfsmount refcounting changes</title>
<updated>2011-01-16T18:47:07Z</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2011-01-15T03:30:21Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=f03c65993b98eeb909a4012ce7833c5857d74755'/>
<id>urn:sha1:f03c65993b98eeb909a4012ce7833c5857d74755</id>
<content type='text'>
Instead of splitting refcount between (per-cpu) mnt_count
and (SMP-only) mnt_longrefs, make all references contribute
to mnt_count again and keep track of how many are longterm
ones.

Accounting rules for longterm count:
	* 1 for each fs_struct.root.mnt
	* 1 for each fs_struct.pwd.mnt
	* 1 for having non-NULL -&gt;mnt_ns
	* decrement to 0 happens only under vfsmount lock exclusive

That allows nice common case for mntput() - since we can't drop the
final reference until after mnt_longterm has reached 0 due to the rules
above, mntput() can grab vfsmount lock shared and check mnt_longterm.
If it turns out to be non-zero (which is the common case), we know
that this is not the final mntput() and can just blindly decrement
percpu mnt_count.  Otherwise we grab vfsmount lock exclusive and
do usual decrement-and-check of percpu mnt_count.

For fs_struct.c we have mnt_make_longterm() and mnt_make_shortterm();
namespace.c uses the latter in places where we don't already hold
vfsmount lock exclusive and opencodes a few remaining spots where
we need to manipulate mnt_longterm.

Note that we mostly revert the code outside of fs/namespace.c back
to what we used to have; in particular, normal code doesn't need
to care about two kinds of references, etc.  And we get to keep
the optimization Nick's variant had bought us...

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
</feed>
