From patchwork Sat Apr 6 04:57:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13619656 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 496422914 for ; Sat, 6 Apr 2024 04:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379431; cv=none; b=GFamPpbP3wXcx/CJUlda+x72GGQB9ByF7nObyiKFN1EpxniJkTc+WK3XUSDTDCL7UYB+4Kf2yXZZuyCajuizjKDF9RcA/eroqZKwzCG+87nOfw06FYh1NJP88/rf5XnyTUfJRw32fBd4GgLSY6m5/JByTlaNWbKFjujFuw1KyVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379431; c=relaxed/simple; bh=sJweHKopMO47UxvxaTZOae60HH2Lz9neUc+4VRu8R0Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fsAIKVwoUgHaXSyeWCBmZGDywz59dm5RrpyvnVEUs728Lbsyjv94ggwLx/945PG1oHiivllYmTSFgvx7DlVDAPzRxMsDa39U/CdLdEV75yIuE22XaB0P/vpPkzz4wxtHPzcreN/qS5uriiKv2MqPhHUfiEHLGpcLeMhsLU3JHu8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=YyU0HWD4; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="YyU0HWD4" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YLOYsjaot/pQqeiI+112iAE+LpXiTY7lGDwpSJmbOYk=; b=YyU0HWD4CJ+MUd7zhGAsj+v+Ye SFjOVWF/jONtVSQ7gIpb8XDzZUvecCzSW2fgjCkuWMbMU17zo941dXITFZ3a52jG8jbrxcS+QimbN uyQzfTDUTz4rtO/M2Ero2m69CDRU1hqlMIS/DA2L4MwXYAEgqX7IqUwmAg6IUQzWNztRRFvXwEhOv ilIg7M9E8rsfA6PO4entLo/UgNB5sWotpWg6MvLFOpGFdPcI/BGi/aJHhC8Mil9NyJkaGRK1YJ4ic /aUi63qg+7NRIqO9NLcfWaVQr4wtBsH9dGSNgKFwCa8aZqPgFvRsUYkAGvB52Y26DG6Hr/qp85irI SjQLSJrQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rsy71-006qgo-1Q; Sat, 06 Apr 2024 04:57:07 +0000 Date: Sat, 6 Apr 2024 05:57:07 +0100 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Christian Brauner Subject: [PATCH 1/6] close_on_exec(): pass files_struct instead of fdtable Message-ID: <20240406045707.GA1632446@ZenIV> References: <20240406045622.GY538574@ZenIV> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240406045622.GY538574@ZenIV> Sender: Al Viro both callers are happier that way... Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/file.c | 5 +---- fs/proc/fd.c | 4 +--- include/linux/fdtable.h | 10 +++++----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/fs/file.c b/fs/file.c index 3b683b9101d8..eff5ce79f66a 100644 --- a/fs/file.c +++ b/fs/file.c @@ -1219,12 +1219,9 @@ void set_close_on_exec(unsigned int fd, int flag) bool get_close_on_exec(unsigned int fd) { - struct files_struct *files = current->files; - struct fdtable *fdt; bool res; rcu_read_lock(); - fdt = files_fdtable(files); - res = close_on_exec(fd, fdt); + res = close_on_exec(fd, current->files); rcu_read_unlock(); return res; } diff --git a/fs/proc/fd.c b/fs/proc/fd.c index 6e72e5ad42bc..0139aae19651 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c @@ -39,10 +39,8 @@ static int seq_show(struct seq_file *m, void *v) spin_lock(&files->file_lock); file = files_lookup_fd_locked(files, fd); if (file) { - struct fdtable *fdt = files_fdtable(files); - f_flags = file->f_flags; - if (close_on_exec(fd, fdt)) + if (close_on_exec(fd, files)) f_flags |= O_CLOEXEC; get_file(file); diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index 78c8326d74ae..cc060b20502b 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -33,11 +33,6 @@ struct fdtable { struct rcu_head rcu; }; -static inline bool close_on_exec(unsigned int fd, const struct fdtable *fdt) -{ - return test_bit(fd, fdt->close_on_exec); -} - static inline bool fd_is_open(unsigned int fd, const struct fdtable *fdt) { return test_bit(fd, fdt->open_fds); @@ -107,6 +102,11 @@ struct file *lookup_fdget_rcu(unsigned int fd); struct file *task_lookup_fdget_rcu(struct task_struct *task, unsigned int fd); struct file *task_lookup_next_fdget_rcu(struct task_struct *task, unsigned int *fd); +static inline bool close_on_exec(unsigned int fd, const struct files_struct *files) +{ + return test_bit(fd, files_fdtable(files)->close_on_exec); +} + struct task_struct; void put_files_struct(struct files_struct *fs); From patchwork Sat Apr 6 04:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13619657 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 0588918C31 for ; Sat, 6 Apr 2024 04:57:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379454; cv=none; b=EGOOV+1as06lrSC9OOFVM3l+3Bn24/M5TAPmgcECNnIWnvJSATXj4mval7XS6MNsL9GJs1eoQ7N9Pa6a9w6VlGGCgWFDeaN7J2GNi1CAcM8ui5D/G7xQ+8gJ9xV8odxZX7AG7gjQrobTL3PQKS3yBvqjP14a6n6YX7R32UG82Ug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379454; c=relaxed/simple; bh=Cm6CBdhHllU/asXgm4TMUIKKPJkKfETsSTCkttiZ0kg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JvY3lMMqRUmTmvidsB+RagpY5nOwi91+iocSKvr/TZan3jAQ1VKz3uKeRg9Gcd/4JFrWLe0tEB33noXm5GcYsxJVyeBRZHA8kJQipyNk6fHXnRui2HqBnC7TAZ4qXcFz3rDYms3dTZWB2QTiv3aNBIRozESZ6uqu9c9OrvNw0eQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=EpL60hls; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="EpL60hls" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=KmrVwDZnt++mPvaAOc1bGKKsxYFWBLqEFsn24V8OyGU=; b=EpL60hlst5HkcSlmfgC+cDKXjD 8uqwd4JKeJX8yB6DPbXJJSecxkFrHrlf2IReOwg4+w4uypVO9q292tvKHRnYymWfPTgd7opp08AVR 9EXUV44mbhzknBddiTB7BZ4TTRZlBQpVkzmE/pNb6z6XSiGF7RdzbASyKEB1VekI4Lrinf5oPfgfX 10WBzbVII64OkUHU5x2UcB2r/ApPwNzciU7Pbdns8dE5KF6ZNb/N9az+fvZx43k2JHe6CQahrzO6w gRUf8AFt5WCqzyJkEzswlDWz39jN1Q3/kipisewGa838kk/49Q3VL/B0anAlM+I6GwLZmYVSsi+oA XSZ1BXcQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rsy7O-006qhZ-1x; Sat, 06 Apr 2024 04:57:30 +0000 Date: Sat, 6 Apr 2024 05:57:30 +0100 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Christian Brauner Subject: [PATCH 2/6] fd_is_open(): move to fs/file.c Message-ID: <20240406045730.GB1632446@ZenIV> References: <20240406045622.GY538574@ZenIV> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240406045622.GY538574@ZenIV> Sender: Al Viro no users outside that... Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/file.c | 5 +++++ include/linux/fdtable.h | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/file.c b/fs/file.c index eff5ce79f66a..ab38b005633c 100644 --- a/fs/file.c +++ b/fs/file.c @@ -271,6 +271,11 @@ static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt) __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits); } +static inline bool fd_is_open(unsigned int fd, const struct fdtable *fdt) +{ + return test_bit(fd, fdt->open_fds); +} + static unsigned int count_open_files(struct fdtable *fdt) { unsigned int size = fdt->max_fds; diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index cc060b20502b..2944d4aa413b 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -33,11 +33,6 @@ struct fdtable { struct rcu_head rcu; }; -static inline bool fd_is_open(unsigned int fd, const struct fdtable *fdt) -{ - return test_bit(fd, fdt->open_fds); -} - /* * Open file table structure */ From patchwork Sat Apr 6 05:00:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13619658 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 95A96139F for ; Sat, 6 Apr 2024 05:00:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379637; cv=none; b=ohxkCRgNjaIXmEylGKJqvqixarnI9s+sKGonJWsENhwbymxzoLoiGaFtb5fyXtS5WM7HSPau8u3ix+huYxzGLW+d+SHh4zndLP3KWGgRr5viMqVH/cMh7QLCAWAb9C59GDtiayVFE/aYajdSzbdf1RvCfmH8goXZmTu/t8QD8Wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379637; c=relaxed/simple; bh=LUcXvVIhRjVpkftVtmBl3micXuLLKp6Y6HCogZ0/byw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dSpQOKWQtj4HBmfR+DBVxOPbKXmVT1vDI4vJk5z4Nx9xn7g0xLRe9ggrONblSeVcngRYtzFNAIiFpAYAEIZKZ7ZpKJBKXXW7uFN70y8Ts/d90IkAI+qAF+OlYOTQ+aMizUHRfAMJVk1EpzDHpjjg2e6Bp9w5Ei6iA0goW7epyHo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=el3qrglN; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="el3qrglN" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=PUUrUyHgmJUU4WZ3A9HQ0pSNDpYFjbemyDM120yZx2o=; b=el3qrglNdgxhZP6Y/VDObTjP9L mEjB4fv0NYWyLBL1UfyccEztgzqjvggAsRs5btMR3G2OZFN3AI0RPNfDDe/tUlynJWXs9guQ2TjR1 AJUZWL7Jcv2RbFjBS/qz1J3CGItEHEdbNs45PdMbfyJ5+1SviMfiwD2qh6PjGzn4cC0YPSaKah3MA 2SbEup9U7FUGAYGVLRfEIIj0Fh/jP76+kqWq/baBvAQ9T+/RUpK61RWo/8RDzhl2c5Yb93+7K2LC0 h+Dqwj4dw6SLz7r4mKCLqKLiUVXEFw2eLehnKa06VE/Gxf/WjRpKtOf2nfBgZRjxXLdGBP3fSRgtH qUuDoNPQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rsyAL-006qqu-2a; Sat, 06 Apr 2024 05:00:33 +0000 Date: Sat, 6 Apr 2024 06:00:33 +0100 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Christian Brauner Subject: [PATCH 3/6] get_file_rcu(): no need to check for NULL separately Message-ID: <20240406050033.GC1632446@ZenIV> References: <20240406045622.GY538574@ZenIV> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240406045622.GY538574@ZenIV> Sender: Al Viro IS_ERR(NULL) is false and IS_ERR() already comes with unlikely()... Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/file.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/file.c b/fs/file.c index ab38b005633c..8076aef9c210 100644 --- a/fs/file.c +++ b/fs/file.c @@ -920,13 +920,8 @@ struct file *get_file_rcu(struct file __rcu **f) struct file __rcu *file; file = __get_file_rcu(f); - if (unlikely(!file)) - return NULL; - - if (unlikely(IS_ERR(file))) - continue; - - return file; + if (!IS_ERR(file)) + return file; } } EXPORT_SYMBOL_GPL(get_file_rcu); From patchwork Sat Apr 6 05:01:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13619659 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 890E3139F for ; Sat, 6 Apr 2024 05:01:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379677; cv=none; b=brYnevNilytlfilQ3HHrudUfNbisSCUnR3sD5SuPoYnf21l+3eV6YvF+XZ8N0PeXOLShtbjp72b0IN/bfpSEBsSmmDfWo2iW28KFe8NXq4r7bBqGlq5ufZZIiFh4gSrjAm73Gikipk4Ux8JWr6IJ/DnoB9Gwtw/KJxxMzJb7nAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379677; c=relaxed/simple; bh=sR3FMMgeHqwRof0Y7TCHibbygr3AoezAIT7SG19ZUX4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HGgG/yer+3+v7T76hzUqjap8AwqAUmsyexXEtv8friOELveyNCAdEdx7Uhiw2zNblsCGhWNB+219zDo1Ya6Vfu5leJUgkhtNQLL1PAGDmRYEBGSfbPzHG69xr/yvj8BSmpPfTJTSnwnY1LiY2lbM8w2YakpP2nQBlARbClwJ6vs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=cCOX/PQJ; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="cCOX/PQJ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FDkf2n0aRhxltmMyBYVa5Vbhi+a/sJrmrvpc/3Ivn90=; b=cCOX/PQJYaSq7PPyWUVhRN7aRw FzF3Q1pNgqhIi0/XTQEzbRN0M8P2ZH+Qwrlzw7FyetLnAkBR+ac+QEDSRjCTYY0sIubDraKBebqWz 3g2VGNkL/nkKpKarBaNVhB0NhA4X5MZW9uTYQg+Ae8h268OF7ctAqqdpGUBCeWj/0/RFIOa0Uy+PE f0Arq+jvjFuTe8rpE/PCuRHJnjXASsxYoPYqmA+BqxbIEpVRpx25M1BUgPHA1nWZe6dNIetg17e2l 8A/Rz/AbSj9RUr08aqhWf6c71uOL/9Pu0tzIc+dIb79dk1FPKjeY0IJoh0VUsT9hsCILcXYuBtNNd qU5rlG2A==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rsyAz-006quK-2n; Sat, 06 Apr 2024 05:01:14 +0000 Date: Sat, 6 Apr 2024 06:01:13 +0100 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Christian Brauner Subject: [PATCH 4/6] kernel_file_open(): get rid of inode argument Message-ID: <20240406050113.GD1632446@ZenIV> References: <20240406045622.GY538574@ZenIV> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240406045622.GY538574@ZenIV> Sender: Al Viro always equal to ->dentry->d_inode of the path argument these days. Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/cachefiles/namei.c | 3 +-- fs/open.c | 5 ++--- fs/overlayfs/util.c | 2 +- include/linux/fs.h | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 7ade836beb58..f53977169db4 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -563,8 +563,7 @@ static bool cachefiles_open_file(struct cachefiles_object *object, */ path.mnt = cache->mnt; path.dentry = dentry; - file = kernel_file_open(&path, O_RDWR | O_LARGEFILE | O_DIRECT, - d_backing_inode(dentry), cache->cache_cred); + file = kernel_file_open(&path, O_RDWR | O_LARGEFILE | O_DIRECT, cache->cache_cred); if (IS_ERR(file)) { trace_cachefiles_vfs_error(object, d_backing_inode(dentry), PTR_ERR(file), diff --git a/fs/open.c b/fs/open.c index ee8460c83c77..ec287ac67e7f 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1155,7 +1155,6 @@ EXPORT_SYMBOL(dentry_create); * kernel_file_open - open a file for kernel internal use * @path: path of the file to open * @flags: open flags - * @inode: the inode * @cred: credentials for open * * Open a file for use by in-kernel consumers. The file is not accounted @@ -1165,7 +1164,7 @@ EXPORT_SYMBOL(dentry_create); * Return: Opened file on success, an error pointer on failure. */ struct file *kernel_file_open(const struct path *path, int flags, - struct inode *inode, const struct cred *cred) + const struct cred *cred) { struct file *f; int error; @@ -1175,7 +1174,7 @@ struct file *kernel_file_open(const struct path *path, int flags, return f; f->f_path = *path; - error = do_dentry_open(f, inode, NULL); + error = do_dentry_open(f, d_inode(path->dentry), NULL); if (error) { fput(f); f = ERR_PTR(error); diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index d285d1d7baad..edc9216f6e27 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -1376,7 +1376,7 @@ int ovl_ensure_verity_loaded(struct path *datapath) * If this inode was not yet opened, the verity info hasn't been * loaded yet, so we need to do that here to force it into memory. */ - filp = kernel_file_open(datapath, O_RDONLY, inode, current_cred()); + filp = kernel_file_open(datapath, O_RDONLY, current_cred()); if (IS_ERR(filp)) return PTR_ERR(filp); fput(filp); diff --git a/include/linux/fs.h b/include/linux/fs.h index 00fc429b0af0..143e967a3af2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1906,7 +1906,7 @@ struct file *kernel_tmpfile_open(struct mnt_idmap *idmap, umode_t mode, int open_flag, const struct cred *cred); struct file *kernel_file_open(const struct path *path, int flags, - struct inode *inode, const struct cred *cred); + const struct cred *cred); int vfs_mkobj(struct dentry *, umode_t, int (*f)(struct dentry *, umode_t, void *), From patchwork Sat Apr 6 05:01:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13619660 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 68E45139F for ; Sat, 6 Apr 2024 05:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379719; cv=none; b=TTm1jQZD3wKLm7UiznjSErEVtIQnYZsXZ+OtPsA14eeyl/UovYi/h+IpPdbOQoNHQk1WHmUGzRsgpLlSM9pT7/eBwKztOQ8HdH1CMF7rAHLnxnjGqOE+YxtuBQXy0KioH94/Qctw4DYrf9dwGeSeg31FpF0VjSyMM5ME1ggf2Cc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379719; c=relaxed/simple; bh=xE83wQdFVgq9sPMbiOB+6Je2NyTHrE6D43OP1ArODg8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YflQTHVSPbbUZAZqV1JVyJGicWpc2fx2EqVNDTn4Hrzyp+Q6Low34yETR4i/Mu2AiCXhKuODnwVjF3EoCj30k3cBWDWv7rLuS95ougGAv0JtLbH5igJTOtPyFq7aySxlFA9aT0WcaHUorLPL/pUbwJOnAOMuWq1vYetc1RFyjuk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=gRELLE2V; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="gRELLE2V" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CGxOdWcJAfP1o/TTxzwLgfFNxhw5fH1U5bP9qm1vJ+I=; b=gRELLE2V4PU4ZTz7PDnPiFiE43 wkyPKXNUdYRZ98W+38AMsdHVm+SWr3mFEg6MasKN2/4kXNIH6sgbf4+AsrPfevWy3KHzBveb8w+fg 7UIOfej2h8MAhHfRgUiiAEgW0f8kc0OAKUGdS3SJgajsbMyG2OsVoGD2qFRl1HugCZ75n+oKYY5RR 1U7xNinAC+qB8Jgx29vFfxBrMlfnHtilRBsz06N77xXP7GJKJd/YKVBLwu3/sK6NCLebBgzrsX8jz RGBWdaVlGLhe1xcXZH6JoH8byGmRx6kq0eiA4bJj5QbgArbEoCx0gfV02YOXUsmRRovDjD4xHpdYF UCwHmubQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rsyBg-006qyA-2J; Sat, 06 Apr 2024 05:01:56 +0000 Date: Sat, 6 Apr 2024 06:01:56 +0100 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Christian Brauner Subject: [PATCH 5/6] do_dentry_open(): kill inode argument Message-ID: <20240406050156.GE1632446@ZenIV> References: <20240406045622.GY538574@ZenIV> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240406045622.GY538574@ZenIV> Sender: Al Viro should've been done as soon as overlayfs stopped messing with fake paths... Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- fs/open.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/open.c b/fs/open.c index ec287ac67e7f..89cafb572061 100644 --- a/fs/open.c +++ b/fs/open.c @@ -902,10 +902,10 @@ static inline int file_get_write_access(struct file *f) } static int do_dentry_open(struct file *f, - struct inode *inode, int (*open)(struct inode *, struct file *)) { static const struct file_operations empty_fops = {}; + struct inode *inode = f->f_path.dentry->d_inode; int error; path_get(&f->f_path); @@ -1047,7 +1047,7 @@ int finish_open(struct file *file, struct dentry *dentry, BUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */ file->f_path.dentry = dentry; - return do_dentry_open(file, d_backing_inode(dentry), open); + return do_dentry_open(file, open); } EXPORT_SYMBOL(finish_open); @@ -1086,7 +1086,7 @@ EXPORT_SYMBOL(file_path); int vfs_open(const struct path *path, struct file *file) { file->f_path = *path; - return do_dentry_open(file, d_backing_inode(path->dentry), NULL); + return do_dentry_open(file, NULL); } struct file *dentry_open(const struct path *path, int flags, @@ -1174,7 +1174,7 @@ struct file *kernel_file_open(const struct path *path, int flags, return f; f->f_path = *path; - error = do_dentry_open(f, d_inode(path->dentry), NULL); + error = do_dentry_open(f, NULL); if (error) { fput(f); f = ERR_PTR(error); From patchwork Sat Apr 6 05:02:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13619661 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 2B7F5139F for ; Sat, 6 Apr 2024 05:02:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379757; cv=none; b=P0i9S0QwPi9j4aJ4X0uZyWUGWlP0QsAUm4zV86TewwygU3/z/85sxvtDmA9Uk8ERPc40pFstzoKwk4a5agx+drbBTYCsJLeN88lvoRFKlQO8cXH9Tc2VoVPnSfxV3y3qTpmU4PxYuzWrPpyF+zaVwJs+CMG8rfX9OfjxX8/qxpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712379757; c=relaxed/simple; bh=zETyBS9MplTWs8W+F8isZHcyAzyohyE2BEaLnJHA+f4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QVPert6UdLzBxX8MP87HyXPGrptMkvu1e91nu4Ok7fD00uI4CtOkLcaV+FdfuY/pt7b35ZHp3e7rneHYzj+Xd4jd9waTdWXW/il9Vl5xudj9Skwo2PisbRwODLPiSANj7jGaiVz+KAXi1o2JsdzTYR13RBobMCRnDYGjJYoJKgQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=GIQHNgVP; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="GIQHNgVP" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=aur0Nt4a1nkHmg+IpYrfUPf5w3lyl6emUYlH5WHvu8k=; b=GIQHNgVP+R8Xw6wkCW7cxR3RJs UmJvaeX1fIbLGC0X8q1D/w+C9YNfzHSPO+/N9A8TB4ys1Vvxzr2xDS8L1ErDyFyr0PHWZhustqY5W SL41fruCZlkbeOjrd8q/+XjQnVremGRsP+dWqntXiEeAeClZCzCT/QHWUqjyoZ/sdrXQP0Jl4IBc7 UKuy0QB3Gf55K8oHY00QcL6EIiXBYlmgWSLge/oyRtOd67bXw3qxNqZm28hbZLNZTYnTIVE4DzZYq iytqZprWdSztw/zztbosJHSTazfa0bt/AsceYHUN8QUpQP7aOo/vwJrWkNEUM2rmZhlu66zCGepFT rAAfDNoQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rsyCH-006r1P-2U; Sat, 06 Apr 2024 05:02:33 +0000 Date: Sat, 6 Apr 2024 06:02:33 +0100 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Christian Brauner Subject: [PATCH 6/6] remove call_{read,write}_iter() functions Message-ID: <20240406050233.GF1632446@ZenIV> References: <20240406045622.GY538574@ZenIV> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240406045622.GY538574@ZenIV> Sender: Al Viro From d8c77afeb9912f5eca06f53cbed7fc618c71b46b Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 28 Aug 2023 17:13:18 +0200 Subject: [PATCH 6/6] remove call_{read,write}_iter() functions These have no clear purpose. This is effectively a revert of commit bb7462b6fd64 ("vfs: use helpers for calling f_op->{read,write}_iter()"). The patch was created with the help of a coccinelle script. Fixes: bb7462b6fd64 ("vfs: use helpers for calling f_op->{read,write}_iter()") Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro Reviewed-by: Christian Brauner --- drivers/block/loop.c | 4 ++-- drivers/target/target_core_file.c | 4 ++-- fs/aio.c | 4 ++-- fs/read_write.c | 12 ++++++------ fs/splice.c | 4 ++-- include/linux/fs.h | 12 ------------ io_uring/rw.c | 4 ++-- 7 files changed, 16 insertions(+), 28 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 28a95fd366fe..93780f41646b 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -445,9 +445,9 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0); if (rw == ITER_SOURCE) - ret = call_write_iter(file, &cmd->iocb, &iter); + ret = file->f_op->write_iter(&cmd->iocb, &iter); else - ret = call_read_iter(file, &cmd->iocb, &iter); + ret = file->f_op->read_iter(&cmd->iocb, &iter); lo_rw_aio_do_completion(cmd); diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 4d447520bab8..94e6cd4e7e43 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -299,9 +299,9 @@ fd_execute_rw_aio(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, aio_cmd->iocb.ki_flags |= IOCB_DSYNC; if (is_write) - ret = call_write_iter(file, &aio_cmd->iocb, &iter); + ret = file->f_op->write_iter(&aio_cmd->iocb, &iter); else - ret = call_read_iter(file, &aio_cmd->iocb, &iter); + ret = file->f_op->read_iter(&aio_cmd->iocb, &iter); if (ret != -EIOCBQUEUED) cmd_rw_aio_complete(&aio_cmd->iocb, ret); diff --git a/fs/aio.c b/fs/aio.c index 9cdaa2faa536..13ca81c7c744 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1605,7 +1605,7 @@ static int aio_read(struct kiocb *req, const struct iocb *iocb, return ret; ret = rw_verify_area(READ, file, &req->ki_pos, iov_iter_count(&iter)); if (!ret) - aio_rw_done(req, call_read_iter(file, req, &iter)); + aio_rw_done(req, file->f_op->read_iter(req, &iter)); kfree(iovec); return ret; } @@ -1636,7 +1636,7 @@ static int aio_write(struct kiocb *req, const struct iocb *iocb, if (S_ISREG(file_inode(file)->i_mode)) kiocb_start_write(req); req->ki_flags |= IOCB_WRITE; - aio_rw_done(req, call_write_iter(file, req, &iter)); + aio_rw_done(req, file->f_op->write_iter(req, &iter)); } kfree(iovec); return ret; diff --git a/fs/read_write.c b/fs/read_write.c index d4c036e82b6c..2de7f6adb33d 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -392,7 +392,7 @@ static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lo kiocb.ki_pos = (ppos ? *ppos : 0); iov_iter_ubuf(&iter, ITER_DEST, buf, len); - ret = call_read_iter(filp, &kiocb, &iter); + ret = filp->f_op->read_iter(&kiocb, &iter); BUG_ON(ret == -EIOCBQUEUED); if (ppos) *ppos = kiocb.ki_pos; @@ -494,7 +494,7 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t kiocb.ki_pos = (ppos ? *ppos : 0); iov_iter_ubuf(&iter, ITER_SOURCE, (void __user *)buf, len); - ret = call_write_iter(filp, &kiocb, &iter); + ret = filp->f_op->write_iter(&kiocb, &iter); BUG_ON(ret == -EIOCBQUEUED); if (ret > 0 && ppos) *ppos = kiocb.ki_pos; @@ -736,9 +736,9 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter, kiocb.ki_pos = (ppos ? *ppos : 0); if (type == READ) - ret = call_read_iter(filp, &kiocb, iter); + ret = filp->f_op->read_iter(&kiocb, iter); else - ret = call_write_iter(filp, &kiocb, iter); + ret = filp->f_op->write_iter(&kiocb, iter); BUG_ON(ret == -EIOCBQUEUED); if (ppos) *ppos = kiocb.ki_pos; @@ -799,7 +799,7 @@ ssize_t vfs_iocb_iter_read(struct file *file, struct kiocb *iocb, if (ret < 0) return ret; - ret = call_read_iter(file, iocb, iter); + ret = file->f_op->read_iter(iocb, iter); out: if (ret >= 0) fsnotify_access(file); @@ -860,7 +860,7 @@ ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb, return ret; kiocb_start_write(iocb); - ret = call_write_iter(file, iocb, iter); + ret = file->f_op->write_iter(iocb, iter); if (ret != -EIOCBQUEUED) kiocb_end_write(iocb); if (ret > 0) diff --git a/fs/splice.c b/fs/splice.c index 218e24b1ac40..60aed8de21f8 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -362,7 +362,7 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, iov_iter_bvec(&to, ITER_DEST, bv, npages, len); init_sync_kiocb(&kiocb, in); kiocb.ki_pos = *ppos; - ret = call_read_iter(in, &kiocb, &to); + ret = in->f_op->read_iter(&kiocb, &to); if (ret > 0) { keep = DIV_ROUND_UP(ret, PAGE_SIZE); @@ -740,7 +740,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out, iov_iter_bvec(&from, ITER_SOURCE, array, n, sd.total_len - left); init_sync_kiocb(&kiocb, out); kiocb.ki_pos = sd.pos; - ret = call_write_iter(out, &kiocb, &from); + ret = out->f_op->write_iter(&kiocb, &from); sd.pos = kiocb.ki_pos; if (ret <= 0) break; diff --git a/include/linux/fs.h b/include/linux/fs.h index 143e967a3af2..a94343f567cb 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2096,18 +2096,6 @@ struct inode_operations { struct offset_ctx *(*get_offset_ctx)(struct inode *inode); } ____cacheline_aligned; -static inline ssize_t call_read_iter(struct file *file, struct kiocb *kio, - struct iov_iter *iter) -{ - return file->f_op->read_iter(kio, iter); -} - -static inline ssize_t call_write_iter(struct file *file, struct kiocb *kio, - struct iov_iter *iter) -{ - return file->f_op->write_iter(kio, iter); -} - static inline int call_mmap(struct file *file, struct vm_area_struct *vma) { return file->f_op->mmap(file, vma); diff --git a/io_uring/rw.c b/io_uring/rw.c index 0585ebcc9773..7d335b7e00ed 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -701,7 +701,7 @@ static inline int io_iter_do_read(struct io_rw *rw, struct iov_iter *iter) struct file *file = rw->kiocb.ki_filp; if (likely(file->f_op->read_iter)) - return call_read_iter(file, &rw->kiocb, iter); + return file->f_op->read_iter(&rw->kiocb, iter); else if (file->f_op->read) return loop_rw_iter(READ, rw, iter); else @@ -1047,7 +1047,7 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags) kiocb->ki_flags |= IOCB_WRITE; if (likely(req->file->f_op->write_iter)) - ret2 = call_write_iter(req->file, kiocb, &s->iter); + ret2 = req->file->f_op->write_iter(kiocb, &s->iter); else if (req->file->f_op->write) ret2 = loop_rw_iter(WRITE, rw, &s->iter); else