When to lock pipe->rd_wait.lock?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm trying to understand the code that allocates a new buffer from a
pipe's buffer ring. I'd like to write a patch that eliminates some
duplicate code, to make it less error prone.

In fs/pipe.c, pipe_write() locks pipe->rd_wait.lock while the pipe's
head gets evaluated and incremented (all while pipe->mutex is locked).
My limited understand is that holding this spinlock is important
because it protects the head/tail accesses in pipe_readable() which is
gets called by wait_event while the spinlock is held, but without
pipe->mutex.

However in fs/splice.c, splice_pipe_to_pipe() contains very similar
code; a new buffer gets allocated, head gets incremented - but without
caring for pipe->rd_wait.lock.
Please help me understand the point of locking pipe->rd_wait.lock, and
why it's necessary in pipe_write() but not in splice_pipe_to_pipe().
Is that a bug or am I missing something?

Max



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux