Skip to content

File descriptor hot-unplug support v2

Eric W. Biederman linux-fsdevel linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest23 patches 44 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23mm: Introduce revoke_file_mappings.include/linux/mm.h mm/memory.c+100 -02 replies
2/23vfs: Implement unpoll_file.fs/select.c include/linux/poll.h+33 -01 reply
3/23vfs: Generalize the file_listdrivers/char/pty.c drivers/char/tty_io.c fs/file_table.c +7 more+102 -835 replies
4/23vfs: Introduce infrastructure for revoking a fileDocumentation/filesystems/vfs.txt fs/Kconfig fs/file_table.c +3 more+202 -1111 replies
5/23vfs: Teach lseek to use file_hotplug_lockfs/read_write.c+17 -70 replies
6/23vfs: Teach read/write to use file_hotplug_read_lockfs/compat.c fs/read_write.c+72 -140 replies
7/23vfs: Teach sendfile,splice,tee,and vmsplice to use file_hotplug_lockfs/read_write.c fs/splice.c+95 -442 replies
8/23vfs: Teach readdir to use file_hotplug_lockfs/readdir.c+15 -50 replies
9/23vfs: Teach poll and select to use file_hotplug_lockfs/select.c include/linux/poll.h+18 -70 replies
10/23vfs: Teach do_path_lookup to use file_hotplug_lockfs/namei.c+9 -20 replies
11/23mm: Teach mmap to use file_hotplug_lockmm/mmap.c mm/nommu.c+70 -270 replies
12/23vfs: Teach fcntl to use file_hotplug_lockfs/fcntl.c+19 -90 replies
13/23vfs: Teach ioctl to use file_hotplug_lockfs/compat_ioctl.c fs/ioctl.c+17 -50 replies
14/23vfs: Teach flock to use file_hotplug_lockfs/locks.c+7 -10 replies
15/23vfs: Teach fallocate, and filp_close to use file_hotplug_lockfs/open.c+17 -50 replies
16/23vfs: Teach fstatfs, fstatfs64, ftruncate, fchdir, fchmod, fchown to use file_hotplug_lockfs/open.c+41 -60 replies
17/23proc: Teach /proc/<pid>/fd to use file_hotplug_lockfs/proc/base.c+16 -130 replies
18/23vfs: Teach epoll to use file_hotplug_lockfs/eventpoll.c+32 -78 replies
19/23eventpoll: Fix commentfs/eventpoll.c+1 -10 replies
20/23vfs: Teach aio to use file_hotplug_lockfs/aio.c+38 -130 replies
21/23vfs: Teach fsync to use file_hotplug_lockfs/sync.c+8 -10 replies
22/23vfs: Teach fadvice to file_hotplug_lockmm/fadvise.c+7 -00 replies
23/23vfs: Teach readahead to use the file_hotplug_lockmm/filemap.c+16 -91 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/23] File descriptor hot-unplug support v2

I found myself looking at the uio, seeing that it does not support pci hot-unplug, and thinking "Great yet another implementation of hotunplug logic that needs to be added".

I decided to see what it would take to add a generic implementation of the code we have for supporting hot unplugging devices in sysfs, proc, sysctl, tty_io, and now almost in the tun driver.

Not long after I touched the tun driver and made it safe to delete the network device while still holding it's file descriptor open I someone else touch the code adding a different feature and my careful work went up in flames. Which brought home another point at the best of it this is ultimately complex tricky code that subsystems should not need to worry about.

What makes this even more interesting is that in the presence of pci hot-unplug it looks like most subsystems and most devices will have to deal with the issue one way or another.

This infrastructure could also be used to implement both force unmounts and sys_revoke. When I could not think of a better name for I have drawn on that and used revoke.

The following changes draw on and generalize the work in tty_io sysfs, proc, and sysctl and move it into the vfs level. Where the basic primitives are running faster, and the solution is more general.

... Changes since version 1.

All of that lead to the first version of this patchset. The feedback I got from that was generally positive but there was a concern about performance when two there are two simultaneous accessors to the tty at the same time.

After looking into the performance concerns of what happens when multiple programs access the same struct file and finding that I could not rule out a performance regression I have gone back and redesigned my mutual exclusion primitive creating something simpler and faster.

I have also changed my synchronization primitives extending them to protect most of what is read-only in struct file today and abandoning rcu-ness of struct file.

Giving up rcu-ness leads to true exclusion and makes the code much easier to think about.

In this patchset is the basic code patchs 1-4 and a conversion of the vfs except for the nfsd entry points. Enough for a reasonable result.

These patches are based on Al's vfs/for-next tree.

The vfs changes in this patchset.

 Documentation/filesystems/vfs.txt |    5 +
 drivers/char/pty.c                |    2 +-
 drivers/char/tty_io.c             |   22 ++--
 fs/Kconfig                        |    4 +
 fs/aio.c                          |   51 +++++--
 fs/compat.c                       |   16 ++-
 fs/compat_ioctl.c                 |   14 ++-
 fs/eventpoll.c                    |   41 +++++-
 fs/fcntl.c                        |   28 +++--
 fs/file_table.c                   |  281 +++++++++++++++++++++++++++++--------
 fs/inode.c                        |    1 +
 fs/ioctl.c                        |    8 +-
 fs/locks.c                        |    8 +-
 fs/namei.c                        |   11 ++-
 fs/open.c                         |   81 +++++++++--
 fs/proc/base.c                    |   29 ++--
 fs/read_write.c                   |  122 ++++++++++++----
 fs/readdir.c                      |   20 ++-
 fs/select.c                       |   53 ++++++-
 fs/splice.c                       |  111 ++++++++++-----
 fs/super.c                        |    1 -
 fs/sync.c                         |    9 +-
 include/linux/fs.h                |   49 ++++++-
 include/linux/mm.h                |    2 +
 include/linux/poll.h              |    3 +
 include/linux/sched.h             |    7 +
 include/linux/tty.h               |    2 +-
 mm/fadvise.c                      |    7 +
 mm/filemap.c                      |   25 ++--
 mm/memory.c                       |   98 +++++++++++++
 mm/mmap.c                         |   78 +++++++----
 mm/nommu.c                        |   21 +++-
 security/selinux/hooks.c          |    8 +-
 33 files changed, 950 insertions(+), 268 deletions(-)

The necessary changes to proc to take advantage of this functionality.

 fs/proc/Kconfig         |    1 +
 fs/proc/generic.c       |   56 +++-----
 fs/proc/inode.c         |  354 ++++-------------------------------------------
 fs/proc/internal.h      |    1 +
 include/linux/proc_fs.h |    4 -
 5 files changed, 44 insertions(+), 372 deletions(-)