From patchwork Fri Jan 5 12:49:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 185385 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6197136dyb; Fri, 5 Jan 2024 04:50:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEoCHSA+fcKL7w39r3S4+AG7doXJZ5oFdlvqTSEka6KaK6mSne5grfRDz0kUgC4Cvu4irGC X-Received: by 2002:a05:6a00:3216:b0:6d9:8b96:d453 with SMTP id bm22-20020a056a00321600b006d98b96d453mr1728069pfb.42.1704459049366; Fri, 05 Jan 2024 04:50:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704459049; cv=none; d=google.com; s=arc-20160816; b=ZinAWikd9r7RwOUf1slBvvQHYLxT3/NJSC+IbrqRSuEfh68i12oxPXmjU0hlzm/ZFF xAiFpTmJ0ftSPnBqo3VSFCj2sEqnlSRWF/j1Ks4K7srl8EB3Twok/YUeq+BYhE8XTpqM zbzdLu6xaEy8tWJ3TxsrUvMR9b5X3seDaPpnf3tqokzoH7p/dL84PBEMCW9eX6pD9NEX 2v9ek3uOPt1+iQTNy5PE4zOP1t/SQyIU/wsnTl6njCsm7re/lL7bQ7MD7m0E/I1HPBBs T6yLr3q1r9u7Z7fd7A4laPB10/+vErd3IEbnqjBVwEfDKZl/tB7ZiHb/gl9QTaZLraFR f1nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=n7DmUXGifwzoXvgtSaGJXM2c0Oqy9dBMJ8PyVyOoJRA=; fh=qDZ+YnS9HJbCVOaeWFr2FnYZt7eE+vt5IJIDIlhBdxU=; b=Sw6nyCugkPgicjT0z29tDvBygBUHn28Y35yOjGO2qmTOqlhZgLb3NUJfYGaKEHkkP6 0mCtfYUsWs8JO6qgIftBZkGcYIVpn6HK/Zh12VAQPMYEMJXds9kms1klCyaQRUQ8/fQ7 Pu3hxc0+1VYxzkeU/lUP9KvW7rBgKy4WJxWwqQDZTiCbhuUylnvJdeQiVTXadVOLJgnD gcmP8DzjD2HAVWTOEqhdhuuXQiPmMUAJSFYdY1mBQ6z8is016us2WQhsHbq8i6F+cqd4 57JoxxVATOZ1MWa0FfstzAqhClZ1XnnGnXv0RFtUJA0zj9fq8hFfxNzGGB1PpTaeQSk0 Wn3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ytl6lCyO; spf=pass (google.com: domain of linux-kernel+bounces-17840-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17840-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h18-20020aa786d2000000b006ce921fc8f6si1257645pfo.187.2024.01.05.04.50.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 04:50:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17840-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ytl6lCyO; spf=pass (google.com: domain of linux-kernel+bounces-17840-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17840-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7CD38B22570 for ; Fri, 5 Jan 2024 12:50:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A9182D626; Fri, 5 Jan 2024 12:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ytl6lCyO" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 132752D043; Fri, 5 Jan 2024 12:50:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25172C433C9; Fri, 5 Jan 2024 12:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704459023; bh=2ulF6/TQ8iLxPsLSmKQRpRjw8sAPwVOnYVIRR+bqtTA=; h=From:To:Cc:Subject:Date:From; b=Ytl6lCyOXU/qx0+ryf3yS1qjXXGXt+l6CpO6zKfgLQyJXkdimDfzr7BGq1v6TdeLe q/n8E4oweEJ6kq7FzafQcbDNyQMj8KChlXQ1ZHRYwaj/usbHNG9esJJfWu12DRJoJ9 zbIqnZ2IyoXAr+T/25QZ+K/LWbEDkePKp7BWhD/DxfBvvvFxgJLSsMtPCEudAhs+CD lcCN/ER6Tna+wf+3f9MLpin+wyJ9M+O3blHkTDIAw9aK9R0VJvy8nlGucEf6+xLzgq oYUOu+rxF9GaN8oto2LcOUIm1m7aa4r0G+h0FDjwysaCERpqUhDoekU3j293xnNpQG 3Dy7PAaOVQHCw== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [GIT PULL] vfs rw updates Date: Fri, 5 Jan 2024 13:49:30 +0100 Message-ID: <20240105-vfs-rw-9b5809292b57@brauner> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6289; i=brauner@kernel.org; h=from:subject:message-id; bh=2ulF6/TQ8iLxPsLSmKQRpRjw8sAPwVOnYVIRR+bqtTA=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRO/3Uj9cOVix8NpIsWqhTN9/4RMd26f6Jl7aqOz2llp 9TvTopv6ShlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZhIcAwjw9J7Z6c4P2+936+/ RmTtvFOdPUEvExKTT5zTEom763Z53wSG/45X0+Z5ZPUui5m37F140mbv6Q2e0gec/jlWstenT86 VZgIA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787254851874616271 X-GMAIL-MSGID: 1787254851874616271 Hey Linus, Based on the discussions at Maintainer's Summit I've encouraged relevant people to provide pulls if they feel comfortable doing so. So this contains a pull from Amir for read-write backing file helpers for stacking filesystems such as overlayfs. /* Summary */ * Fanotify is currently in the process of introducing pre content events. Roughly, a new permission event will be added indicating that it is safe to write to the file being accessed. These events are used by hierarchical storage managers to e.g., fill the content of files on first access. During that work we noticed that our current permission checking is inconsistent in rw_verify_area() and remap_verify_area(). Especially in the splice code permission checking is done multiple times. For example, one time for the whole range and then again for partial ranges inside the iterator. In addition, we mostly do permission checking before we call file_start_write() except for a few places where we call it after. For pre-content events we need such permission checking to be done before file_start_write(). So this is a nice reason to clean this all up. After this series, all permission checking is done before file_start_write(). As part of this cleanup we also massaged the splice code a bit. We got rid of a few helpers because we are alredy drowning in special read-write helpers. We also cleaned up the return types for splice helpers. * Introduce generic read-write helpers for backing files. This lifts some overlayfs code to common code so it can be used by the FUSE passthrough work coming in over the next cycles. Make Amir and Miklos the maintainers for this new subsystem of the vfs. /* Testing */ clang: Debian clang version 16.0.6 (19) gcc: (Debian 13.2.0-7) 13.2.0 All patches are based on v6.7-rc1 and have been sitting in linux-next. No build failures or warnings were observed. /* Conflicts */ At the time of creating this PR no merge conflicts were reported from linux-next and no merge conflicts showed up doing a test-merge with current mainline. The following changes since commit b85ea95d086471afb4ad062012a4d73cd328fa86: Linux 6.7-rc1 (2023-11-12 16:19:07 -0800) are available in the Git repository at: git@gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs tags/vfs-6.8.rw for you to fetch changes up to c39e2ae3943d4ee278af4e1b1dcfd5946da1089b: fs: fix __sb_write_started() kerneldoc formatting (2023-12-28 11:40:40 +0100) Please consider pulling these changes from the signed vfs-6.8.rw tag. Happy New Year! Christian ---------------------------------------------------------------- vfs-6.8.rw ---------------------------------------------------------------- Amir Goldstein (29): scsi: target: core: add missing file_{start,end}_write() ovl: add permission hooks outside of do_splice_direct() splice: remove permission hook from do_splice_direct() splice: move permission hook out of splice_direct_to_actor() splice: move permission hook out of splice_file_to_pipe() splice: remove permission hook from iter_file_splice_write() remap_range: move permission hooks out of do_clone_file_range() remap_range: move file_start_write() to after permission hook btrfs: move file_start_write() to after permission hook coda: change locking order in coda_file_write_iter() fs: move file_start_write() into vfs_iter_write() fs: move permission hook out of do_iter_write() fs: move permission hook out of do_iter_read() fs: move kiocb_start_write() into vfs_iocb_iter_write() fs: create __sb_write_started() helper fs: create file_write_started() helper fs: create {sb,file}_write_not_started() helpers fs: fork splice_file_range() from do_splice_direct() fs: move file_start_write() into direct_splice_actor() fs: use do_splice_direct() for nfsd/ksmbd server-side-copy splice: return type ssize_t from all helpers fs: use splice_copy_file_range() inline helper fsnotify: split fsnotify_perm() into two hooks fsnotify: assert that file_start_write() is not held in permission hooks fsnotify: optionally pass access range in file permission hooks fs: prepare for stackable filesystems backing file helpers fs: factor out backing_file_{read,write}_iter() helpers fs: factor out backing_file_splice_{read,write}() helpers fs: factor out backing_file_mmap() helper Christian Brauner (1): Merge tag 'ovl-vfs-6.8' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/overlayfs/vfs Vegard Nossum (1): fs: fix __sb_write_started() kerneldoc formatting MAINTAINERS | 9 ++ drivers/block/loop.c | 2 - fs/Kconfig | 4 + fs/Makefile | 1 + fs/backing-file.c | 336 +++++++++++++++++++++++++++++++++++++++++++ fs/btrfs/ioctl.c | 12 +- fs/cachefiles/io.c | 5 +- fs/ceph/file.c | 13 +- fs/coda/file.c | 2 - fs/fuse/file.c | 5 +- fs/internal.h | 8 +- fs/nfs/nfs4file.c | 5 +- fs/nfsd/vfs.c | 7 +- fs/open.c | 42 +----- fs/overlayfs/Kconfig | 1 + fs/overlayfs/copy_up.c | 30 +++- fs/overlayfs/file.c | 247 +++++-------------------------- fs/overlayfs/overlayfs.h | 8 +- fs/overlayfs/super.c | 11 +- fs/read_write.c | 235 ++++++++++++++++-------------- fs/readdir.c | 4 + fs/remap_range.c | 45 +++--- fs/smb/client/cifsfs.c | 5 +- fs/splice.c | 243 +++++++++++++++++++------------ include/linux/backing-file.h | 42 ++++++ include/linux/fs.h | 71 +++++++-- include/linux/fsnotify.h | 50 +++++-- include/linux/splice.h | 51 ++++--- io_uring/splice.c | 4 +- security/security.c | 10 +- 30 files changed, 941 insertions(+), 567 deletions(-) create mode 100644 fs/backing-file.c create mode 100644 include/linux/backing-file.h