From patchwork Fri Oct 18 23:19:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842485 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 7CA2A152E12 for ; Fri, 18 Oct 2024 23:19:18 +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=1729293561; cv=none; b=B8Zur4AZfORvZGYfRi+uT/q3anz2Pyt2qrb4sUOT40C50YLgpXvVixFfM0RdBSA4lh8xL3FNHA9QLKXvjc4pWNcz1AxnnfHZ+hZrzwPnPbAOV9xWpugJ9q10TNdByBKPk6VSubLZJowpZI3SjSSuW3cAL08ULtogwkHa08PBkzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293561; c=relaxed/simple; bh=gwqFjOJExb5iTfLmZTA9qRgfJlhcnGzl3QKZQcFgveM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F6F3O8CIIkdfA9dQKBO3S5M87pBzD8Y9pGlGTdSAUzrd6pxaJoYtd5BhFDVxu5B3jTrYIw2kD4isCWZ3KWghDtRncGeWvRUVBH9cm6CXO/F4ClxWThjtmlaFeni5dWcA7t5QCSoPy3N2gWiRK2u2MzeskebaBHtlms4vdOquJNU= 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=Y7w7/yS9; 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="Y7w7/yS9" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=ueXIH9q/kM9DCxKgc3jrPn5DjzZoc30guIDVUWRVb/E=; b=Y7w7/yS93thjPzWxllHUHGj9lK 1Qh8SFPnEFUKfnlacTFx/Mp7nXHhry13m5Ozq5SAcpykh05+AbJp97xNWrWUJjdmEN0CqIOsCWhTd AEQMksWLUbCpRIjwHAF59VUB8eiOEFxaO+19CgU1gUdp/daHSKvoQ5qiFQJP35r6up8zHoqCe4PuJ 83c8IMo6HIHW5nnWvc+luf+jEnGhWqWbirrXrcQeebbLM5xxxw2ADwn2ohZMP7V2C62hmsfG250wv BNJj3Me/Li4j0ru8Vq4qvwxZeimzrJ6r9lPSuw/kkbbnAUoZNGkxLDtFRiD5EszR0FSPk6HOQqUpN 67HEcY1w==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFY-00000005E6F-3n04; Fri, 18 Oct 2024 23:19:16 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 01/17] ufs: fix handling of delete_entry and set_link failures Date: Sat, 19 Oct 2024 00:19:00 +0100 Message-ID: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231428.GC1172273@ZenIV> References: <20241018231428.GC1172273@ZenIV> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro similar to minixfs series - make ufs_set_link() report failures, lift folio_release_kmap() into the callers of ufs_set_link() and ufs_delete_entry(), make ufs_rename() handle failures in both. Signed-off-by: Al Viro --- fs/ufs/dir.c | 29 ++++++++++++++--------------- fs/ufs/namei.c | 39 +++++++++++++++++---------------------- fs/ufs/ufs.h | 4 ++-- 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index d6e6a2198971..88d0062cfdb9 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -81,10 +81,9 @@ ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr) } -/* Releases the page */ -void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, - struct folio *folio, struct inode *inode, - bool update_times) +int ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, + struct folio *folio, struct inode *inode, + bool update_times) { loff_t pos = folio_pos(folio) + offset_in_folio(folio, de); unsigned len = fs16_to_cpu(dir->i_sb, de->d_reclen); @@ -92,17 +91,19 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, folio_lock(folio); err = ufs_prepare_chunk(folio, pos, len); - BUG_ON(err); + if (unlikely(err)) { + folio_unlock(folio); + return err; + } de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino); ufs_set_de_type(dir->i_sb, de, inode->i_mode); ufs_commit_chunk(folio, pos, len); - folio_release_kmap(folio, de); if (update_times) inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); mark_inode_dirty(dir); - ufs_handle_dirsync(dir); + return ufs_handle_dirsync(dir); } static bool ufs_check_folio(struct folio *folio, char *kaddr) @@ -505,8 +506,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, if (de->d_reclen == 0) { ufs_error(inode->i_sb, __func__, "zero-length directory entry"); - err = -EIO; - goto out; + return -EIO; } pde = de; de = ufs_next_entry(sb, de); @@ -516,18 +516,17 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, pos = folio_pos(folio) + from; folio_lock(folio); err = ufs_prepare_chunk(folio, pos, to - from); - BUG_ON(err); + if (unlikely(err)) { + folio_unlock(folio); + return err; + } if (pde) pde->d_reclen = cpu_to_fs16(sb, to - from); dir->d_ino = 0; ufs_commit_chunk(folio, pos, to - from); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); mark_inode_dirty(inode); - err = ufs_handle_dirsync(inode); -out: - folio_release_kmap(folio, kaddr); - UFSD("EXIT\n"); - return err; + return ufs_handle_dirsync(inode); } int ufs_make_empty(struct inode * inode, struct inode *dir) diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index c8390976ab6a..38a024c8cccd 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c @@ -210,20 +210,18 @@ static int ufs_unlink(struct inode *dir, struct dentry *dentry) struct inode * inode = d_inode(dentry); struct ufs_dir_entry *de; struct folio *folio; - int err = -ENOENT; + int err; de = ufs_find_entry(dir, &dentry->d_name, &folio); if (!de) - goto out; + return -ENOENT; err = ufs_delete_entry(dir, de, folio); - if (err) - goto out; - - inode_set_ctime_to_ts(inode, inode_get_ctime(dir)); - inode_dec_link_count(inode); - err = 0; -out: + if (!err) { + inode_set_ctime_to_ts(inode, inode_get_ctime(dir)); + inode_dec_link_count(inode); + } + folio_release_kmap(folio, de); return err; } @@ -253,14 +251,14 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, struct ufs_dir_entry * dir_de = NULL; struct folio *old_folio; struct ufs_dir_entry *old_de; - int err = -ENOENT; + int err; if (flags & ~RENAME_NOREPLACE) return -EINVAL; old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_folio); if (!old_de) - goto out; + return -ENOENT; if (S_ISDIR(old_inode->i_mode)) { err = -EIO; @@ -281,7 +279,10 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_folio); if (!new_de) goto out_dir; - ufs_set_link(new_dir, new_de, new_folio, old_inode, 1); + err = ufs_set_link(new_dir, new_de, new_folio, old_inode, 1); + folio_release_kmap(new_folio, new_de); + if (err) + goto out_dir; inode_set_ctime_current(new_inode); if (dir_de) drop_nlink(new_inode); @@ -299,26 +300,20 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, * rename. */ inode_set_ctime_current(old_inode); - - ufs_delete_entry(old_dir, old_de, old_folio); mark_inode_dirty(old_inode); - if (dir_de) { + err = ufs_delete_entry(old_dir, old_de, old_folio); + if (!err && dir_de) { if (old_dir != new_dir) - ufs_set_link(old_inode, dir_de, dir_folio, new_dir, 0); - else - folio_release_kmap(dir_folio, dir_de); + err = ufs_set_link(old_inode, dir_de, dir_folio, + new_dir, 0); inode_dec_link_count(old_dir); } - return 0; - - out_dir: if (dir_de) folio_release_kmap(dir_folio, dir_de); out_old: folio_release_kmap(old_folio, old_de); -out: return err; } diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index a2c762cb65a0..c7638e62ffe8 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h @@ -108,8 +108,8 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *, const struct qstr *, int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct folio *); int ufs_empty_dir(struct inode *); struct ufs_dir_entry *ufs_dotdot(struct inode *, struct folio **); -void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, - struct folio *folio, struct inode *inode, bool update_times); +int ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, + struct folio *folio, struct inode *inode, bool update_times); /* file.c */ extern const struct inode_operations ufs_file_inode_operations; From patchwork Fri Oct 18 23:19:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842477 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 9373718E758 for ; Fri, 18 Oct 2024 23:19:18 +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=1729293560; cv=none; b=YF7kGH33ooxJJeG/+Q2mZRA/bMipIvhabkFsDQBk2oraf/UDpNf00N2liOA0dOF+oSXNMFLaVtxLKnc0Df6+sPavgCHGFvwy3cfl0jCKDGuKhxxdXpNNZts7v+p+LXI9SWa+Uo5augfjc5NmH05fZ7SGWrSYbQK70VcQLQFTFcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293560; c=relaxed/simple; bh=9c1GEpmG8P1WjBS3aHlZgkSloQ/Eix7yHIdoWQhIOJA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q/BdUC3IbKMF8t94rgtqNM1TXOJhC4PpdPLmjmSEHs38JD5blPKjTpudAzssbtNg3ZlGwDHyM87KhSaLyZRq17NBNC68rrwpc2aqOKErif8aLELMsHs8n0V7fvvhDe3wDYauPOjBKtx7Hz3g8bbGRy7z0nSo6AsLtOZRc0phWOA= 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=kJ1fQRN/; 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="kJ1fQRN/" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=lEAlhW5WGeSHUIINYiIBmYi15+zUGHQ/Gwg+oSFVaV8=; b=kJ1fQRN/yZBZaaUL554St+5ACe 6AF2Lem0gYrM9iYXRns6nkwMGU39Q+/NahwhBMLRLXhht3u7OQ9Mjvoaev49lNQuIdkapN2oreuAg wtaGJO45i95NYQIW+tnDmWq1fchSdLsXACEHZSzbms1noBmRbHgVtIcyqnbankLHOEPb/TsVXGwpS m7qf9UK1V8QIBP4SDToMHU8TDmjSXJUMgj2Vmuv7KLmGPNf0Vkwb5JMIfJNp+sRptzi3vhClj1aIk u+zhaX4JUCh+bxJVoptR7fIP7lS+WrzQCkbQAlREa4Pq5WITxh7uVAtsLbV5mT6DbH3S/5WVY0Wrd kbLEwLUg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFY-00000005E6H-49qL; Fri, 18 Oct 2024 23:19:16 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 02/17] ufs: missing ->splice_write() Date: Sat, 19 Oct 2024 00:19:01 +0100 Message-ID: <20241018231916.1245836-2-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro normal ->write_iter()-based ->splice_write() works here just fine... Signed-off-by: Al Viro --- fs/ufs/file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ufs/file.c b/fs/ufs/file.c index 6558882a89ef..487ad1fc2de6 100644 --- a/fs/ufs/file.c +++ b/fs/ufs/file.c @@ -42,4 +42,5 @@ const struct file_operations ufs_file_operations = { .open = generic_file_open, .fsync = generic_file_fsync, .splice_read = filemap_splice_read, + .splice_write = iter_file_splice_write, }; From patchwork Fri Oct 18 23:19:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842484 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 936E118C337 for ; Fri, 18 Oct 2024 23:19:18 +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=1729293561; cv=none; b=CkGTU7RB4mr3Np2Y0ASVLV3aJPgjJX5obNi7T8upmbpiOAXAFCvPuHIxuf18HKaKMfBDLigPV9+XdvnK1WBcsUG2rcZJxhSW+/wfZHKkPLS5gt3BpNiwJPE5SisUFcCgpCgggGNJRF+suFC4YJH82eqdoOvTe+KObk6E4DNQkFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293561; c=relaxed/simple; bh=vnzIg5kE7r+4SApsjTYWZ4HjRybsWwSHpA2t5Yptf8E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kN4mKwmD+0DJeriwu34drObLqUIWIaT6ufKQWa+7BuHTSRSpGy6ci+VkphPoe8nqihQkF8f07FmsI97rrTBJDmB3wFnH1B5edDEY/rYHDobQMp64lzA7oh7vHRSKeMrrk1Zj6vplOmqnjL0LML/RubulSNaPi6MvFadnOjOeA28= 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=CGOcPkEU; 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="CGOcPkEU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=cnMrUTWevv3MUskMWw1NuhwP3T0nyvE0W8GADW2xL5Q=; b=CGOcPkEUaqO4XOVvVRVMrGP1x1 QGeAQMwUxQ+95yQPxTlV3720ePadzDer3BLRTUJUrMmCnqIbJzRHedOMDSct3N0VxRSPx1XoZrfbk Wf+h5p1rTN0L9m+ATt8CRWUtBorYZr6nQFVR8QPMYyclT6WSKXDuI2fgZSh1oT3qU/EFnlFBqJBGO LvMJ1+p0cHOB3q5MGoDihNhoZ29VG0wb3lMOhWiLBOTbU2Ib36yy11qTS2fGxFJJUVQVeC42HoMRc qwBbey3/wwtG0dWDjl/Ngw12PUT+osMJ3mmxxO7nViS5PLalCVrpAbuxoU5P5sc44I6fflwY3RcJo bX79Zc3w==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E6J-0IPe; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 03/17] ufs: fix ufs_read_cylinder() failure handling Date: Sat, 19 Oct 2024 00:19:02 +0100 Message-ID: <20241018231916.1245836-3-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro 1) ufs_load_cylinder() should return NULL on ufs_read_cylinder() failures. ufs_error() is not enough. As it is, IO failure on attempt to read a part of cylinder group metadata is likely to end up with an oops. 2) we drop the wrong buffer heads when undoing sb_bread() on IO failure halfway through the read - we need to brelse() what we've got from sb_bread(), TYVM... Signed-off-by: Al Viro --- fs/ufs/cylinder.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/fs/ufs/cylinder.c b/fs/ufs/cylinder.c index 1abe5454de47..a2813270c303 100644 --- a/fs/ufs/cylinder.c +++ b/fs/ufs/cylinder.c @@ -26,7 +26,7 @@ * Read cylinder group into cache. The memory space for ufs_cg_private_info * structure is already allocated during ufs_read_super. */ -static void ufs_read_cylinder (struct super_block * sb, +static bool ufs_read_cylinder(struct super_block *sb, unsigned cgno, unsigned bitmap_nr) { struct ufs_sb_info * sbi = UFS_SB(sb); @@ -46,9 +46,11 @@ static void ufs_read_cylinder (struct super_block * sb, * We have already the first fragment of cylinder group block in buffer */ UCPI_UBH(ucpi)->bh[0] = sbi->s_ucg[cgno]; - for (i = 1; i < UCPI_UBH(ucpi)->count; i++) - if (!(UCPI_UBH(ucpi)->bh[i] = sb_bread(sb, UCPI_UBH(ucpi)->fragment + i))) + for (i = 1; i < UCPI_UBH(ucpi)->count; i++) { + UCPI_UBH(ucpi)->bh[i] = sb_bread(sb, UCPI_UBH(ucpi)->fragment + i); + if (!UCPI_UBH(ucpi)->bh[i]) goto failed; + } sbi->s_cgno[bitmap_nr] = cgno; ucpi->c_cgx = fs32_to_cpu(sb, ucg->cg_cgx); @@ -67,13 +69,14 @@ static void ufs_read_cylinder (struct super_block * sb, ucpi->c_clusteroff = fs32_to_cpu(sb, ucg->cg_u.cg_44.cg_clusteroff); ucpi->c_nclusterblks = fs32_to_cpu(sb, ucg->cg_u.cg_44.cg_nclusterblks); UFSD("EXIT\n"); - return; + return true; failed: for (j = 1; j < i; j++) - brelse (sbi->s_ucg[j]); + brelse(UCPI_UBH(ucpi)->bh[j]); sbi->s_cgno[bitmap_nr] = UFS_CGNO_EMPTY; ufs_error (sb, "ufs_read_cylinder", "can't read cylinder group block %u", cgno); + return false; } /* @@ -156,15 +159,14 @@ struct ufs_cg_private_info * ufs_load_cylinder ( UFSD("EXIT (FAILED)\n"); return NULL; } - else { - UFSD("EXIT\n"); - return sbi->s_ucpi[cgno]; - } } else { - ufs_read_cylinder (sb, cgno, cgno); - UFSD("EXIT\n"); - return sbi->s_ucpi[cgno]; + if (unlikely(!ufs_read_cylinder (sb, cgno, cgno))) { + UFSD("EXIT (FAILED)\n"); + return NULL; + } } + UFSD("EXIT\n"); + return sbi->s_ucpi[cgno]; } /* * Cylinder group number cg is in cache but it was not last used, @@ -195,7 +197,10 @@ struct ufs_cg_private_info * ufs_load_cylinder ( sbi->s_ucpi[j] = sbi->s_ucpi[j-1]; } sbi->s_ucpi[0] = ucpi; - ufs_read_cylinder (sb, cgno, 0); + if (unlikely(!ufs_read_cylinder (sb, cgno, 0))) { + UFSD("EXIT (FAILED)\n"); + return NULL; + } } UFSD("EXIT\n"); return sbi->s_ucpi[0]; From patchwork Fri Oct 18 23:19:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842482 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 B032718FC99 for ; Fri, 18 Oct 2024 23:19:18 +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=1729293561; cv=none; b=sBjB3Y/DSH4OOgbQAYTv7SJ9QwHRDCKK6PrY1RcsGRJDcfxuvsN+DPt9WS3Shlxf+1dmu/Wwej48NBmva9N0wy8FWgtYDGgvJP32sE2hV4Pz43u4d/RNeZe5dr0zkC+7GwC1zkGBP4xIAS2Tgq2m9p1W2JSmLAyjRpiItd7Lzzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293561; c=relaxed/simple; bh=o8pSp0IrTxeOo0HjTx22NXnCaZ09CDsUwT6c9lcR71g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FNgbfea6v+jC0phubhHLCiALupq2Ho1S0oer1SJkvFGv/eI7Oew/EiVi85LKU+gyQQS6zdcwI800esu+HoRvRPqyu2NOwfi20c9zENDgupwFNdCEow7XQkiIgHHxDbOlcO+6EabpbwFZtYh5KH6dDyzheoPqwygoqOCGUf+b4o8= 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=VL/rlYfi; 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="VL/rlYfi" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=z9/oNAMbW15hF3u9s5+Z+RqEND71MHH/NHQbs7zD1UU=; b=VL/rlYfiIsAp2kXDZ8VTAeW6ww JkgHipBIWjttWt9WMLvkfjDttDs/FuLHx+DQb0aCWBQzI1+0D4eZR1l3vmLFreTb3qOYcKBNakOQm yxpUWglK6q9BEE5MYLKOIrDlk2JSa4YIuewDGDiru53ZxMlBmm+Wk94eP+wa3MXtxaQXSOodTJXHR XdbyjGpVBYknPuPM1soCVVX/rDAOut1kqRAmiXDPd+WWznLqweWPQ9P/y1WUYDPbUYYExC7HwSQF2 o34ZFH/uckzICUWUVqoCNvsS6RPKZhLmVbs+GUfS1OUqOmGaH1e7/UkuL4q45yhW1R5LxkHrNTPvd Xhq0EUzw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E6T-0eZ4; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 04/17] ufs: untangle ubh_...block...() macros, part 1 Date: Sat, 19 Oct 2024 00:19:03 +0100 Message-ID: <20241018231916.1245836-4-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro passing implicit argument to a macro by having it in a variable with special name is Not Nice(tm); just pass it explicitly. kill an unused macro, while we are at it... Signed-off-by: Al Viro --- fs/ufs/balloc.c | 10 +++++----- fs/ufs/util.h | 11 +++-------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index 53c11be2b2c1..e412ddcfda03 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -95,7 +95,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) * Trying to reassemble free fragments into block */ blkno = ufs_fragstoblks (bbase); - if (ubh_isblockset(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno)) { + if (ubh_isblockset(uspi, UCPI_UBH(ucpi), ucpi->c_freeoff, blkno)) { fs32_sub(sb, &ucg->cg_cs.cs_nffree, uspi->s_fpb); uspi->cs_total.cs_nffree -= uspi->s_fpb; fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, uspi->s_fpb); @@ -182,10 +182,10 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count) for (i = bit; i < end_bit; i += uspi->s_fpb) { blkno = ufs_fragstoblks(i); - if (ubh_isblockset(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno)) { + if (ubh_isblockset(uspi, UCPI_UBH(ucpi), ucpi->c_freeoff, blkno)) { ufs_error(sb, "ufs_free_blocks", "freeing free fragment"); } - ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); + ubh_setblock(uspi, UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); inode_sub_bytes(inode, uspi->s_fpb << uspi->s_fshift); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) ufs_clusteracct (sb, ucpi, blkno, 1); @@ -716,7 +716,7 @@ static u64 ufs_alloccg_block(struct inode *inode, /* * If the requested block is available, use it. */ - if (ubh_isblockset(UCPI_UBH(ucpi), ucpi->c_freeoff, ufs_fragstoblks(goal))) { + if (ubh_isblockset(uspi, UCPI_UBH(ucpi), ucpi->c_freeoff, ufs_fragstoblks(goal))) { result = goal; goto gotit; } @@ -730,7 +730,7 @@ static u64 ufs_alloccg_block(struct inode *inode, if (!try_add_frags(inode, uspi->s_fpb)) return 0; blkno = ufs_fragstoblks(result); - ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); + ubh_clrblock(uspi, UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) ufs_clusteracct (sb, ucpi, blkno, -1); diff --git a/fs/ufs/util.h b/fs/ufs/util.h index bf708b68f150..729bc55398f2 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h @@ -455,10 +455,7 @@ static inline unsigned _ubh_find_last_zero_bit_( return (base << uspi->s_bpfshift) + pos - begin; } -#define ubh_isblockclear(ubh,begin,block) (!_ubh_isblockset_(uspi,ubh,begin,block)) - -#define ubh_isblockset(ubh,begin,block) _ubh_isblockset_(uspi,ubh,begin,block) -static inline int _ubh_isblockset_(struct ufs_sb_private_info * uspi, +static inline int ubh_isblockset(struct ufs_sb_private_info * uspi, struct ufs_buffer_head * ubh, unsigned begin, unsigned block) { u8 mask; @@ -478,8 +475,7 @@ static inline int _ubh_isblockset_(struct ufs_sb_private_info * uspi, return 0; } -#define ubh_clrblock(ubh,begin,block) _ubh_clrblock_(uspi,ubh,begin,block) -static inline void _ubh_clrblock_(struct ufs_sb_private_info * uspi, +static inline void ubh_clrblock(struct ufs_sb_private_info * uspi, struct ufs_buffer_head * ubh, unsigned begin, unsigned block) { switch (uspi->s_fpb) { @@ -498,8 +494,7 @@ static inline void _ubh_clrblock_(struct ufs_sb_private_info * uspi, } } -#define ubh_setblock(ubh,begin,block) _ubh_setblock_(uspi,ubh,begin,block) -static inline void _ubh_setblock_(struct ufs_sb_private_info * uspi, +static inline void ubh_setblock(struct ufs_sb_private_info * uspi, struct ufs_buffer_head * ubh, unsigned begin, unsigned block) { switch (uspi->s_fpb) { From patchwork Fri Oct 18 23:19:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842490 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 D1D6318FDA6 for ; Fri, 18 Oct 2024 23:19:18 +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=1729293562; cv=none; b=OVWKT7Me2l/EO78s3myhw1uIjrCCzs15/n0RFOTdPDJiNOZPkyNOBOYfravblaD5ywabN7N2mkJ+lJwfG+kZggYtCKUW4iKe9O58djBZ1yGSJ80ajETB2SJ9iBNqlsTEc9PJ9ldf4pSF4c/uW5PfuHGLTzWDEIbUJcUhzZ+yr+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293562; c=relaxed/simple; bh=XOnVHF6dXO3Ivt2gd0u6OrKU8qrlT8bgdpFkoozptUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HCdy25T/8Em4kU/MS8cRJUpUROZ3t0tV+9jBtX3kO+TSmLIU2kZJNfN4rYDeML3tXWO5KlrCLHlyaSZybLFqq8lwcoWyl4vPQxs2eIVyk/CNFIv0yvZohZQYHNKdlZnF5iwRRf75ic4+oiAOLRR1tNlXmx/7oKwUegDaZ74c08E= 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=hKMgt7Y/; 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="hKMgt7Y/" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=gpcfBgA2ce/B4YO54z7L3tTLaHGnCVJmJuXYnYqg95k=; b=hKMgt7Y/G8mwR0GNvsRaSei7ra BsrDh4zHFhIleq6Mp92je7FRb0360Xh1fQcmdez5snwdWm/gkyFd/VpERAPrR+a7G8Bjkhj0GLVAR AflKhie9oOQrJA4zGM8gMdoSU1YWWy9qEpw5m4j6mOR7xF/F8kZr1hwASGsL/jvDvwxoGjsUaThb1 Pdu6sP02jGmVORStTgMHfgTN698kFzaZYe5FoTH7XxrPjA9RIulD3AlNc/tDNY8tjbJFGb+s3NQc4 Dd9Qn0WMUKGPSuu81ZTyFvjTZhIHHdjxliCczawA1sdSjOmUbzS6apPQdQavLdUtYOG/h2Jubt5Pc i6Go17qw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E6Z-1DMm; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 05/17] ufs: untangle ubh_...block...(), part 2 Date: Sat, 19 Oct 2024 00:19:04 +0100 Message-ID: <20241018231916.1245836-5-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro pass cylinder group descriptor instead of its buffer head (ubh, always UCPI_UBH(ucpi)) and its ->c_freeoff. Signed-off-by: Al Viro --- fs/ufs/balloc.c | 10 +++++----- fs/ufs/util.h | 16 +++++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index e412ddcfda03..d76c04fbd4fa 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -95,7 +95,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) * Trying to reassemble free fragments into block */ blkno = ufs_fragstoblks (bbase); - if (ubh_isblockset(uspi, UCPI_UBH(ucpi), ucpi->c_freeoff, blkno)) { + if (ubh_isblockset(uspi, ucpi, blkno)) { fs32_sub(sb, &ucg->cg_cs.cs_nffree, uspi->s_fpb); uspi->cs_total.cs_nffree -= uspi->s_fpb; fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, uspi->s_fpb); @@ -182,10 +182,10 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count) for (i = bit; i < end_bit; i += uspi->s_fpb) { blkno = ufs_fragstoblks(i); - if (ubh_isblockset(uspi, UCPI_UBH(ucpi), ucpi->c_freeoff, blkno)) { + if (ubh_isblockset(uspi, ucpi, blkno)) { ufs_error(sb, "ufs_free_blocks", "freeing free fragment"); } - ubh_setblock(uspi, UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); + ubh_setblock(uspi, ucpi, blkno); inode_sub_bytes(inode, uspi->s_fpb << uspi->s_fshift); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) ufs_clusteracct (sb, ucpi, blkno, 1); @@ -716,7 +716,7 @@ static u64 ufs_alloccg_block(struct inode *inode, /* * If the requested block is available, use it. */ - if (ubh_isblockset(uspi, UCPI_UBH(ucpi), ucpi->c_freeoff, ufs_fragstoblks(goal))) { + if (ubh_isblockset(uspi, ucpi, ufs_fragstoblks(goal))) { result = goal; goto gotit; } @@ -730,7 +730,7 @@ static u64 ufs_alloccg_block(struct inode *inode, if (!try_add_frags(inode, uspi->s_fpb)) return 0; blkno = ufs_fragstoblks(result); - ubh_clrblock(uspi, UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); + ubh_clrblock(uspi, ucpi, blkno); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) ufs_clusteracct (sb, ucpi, blkno, -1); diff --git a/fs/ufs/util.h b/fs/ufs/util.h index 729bc55398f2..c7196a81fb0d 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h @@ -455,9 +455,11 @@ static inline unsigned _ubh_find_last_zero_bit_( return (base << uspi->s_bpfshift) + pos - begin; } -static inline int ubh_isblockset(struct ufs_sb_private_info * uspi, - struct ufs_buffer_head * ubh, unsigned begin, unsigned block) +static inline int ubh_isblockset(struct ufs_sb_private_info *uspi, + struct ufs_cg_private_info *ucpi, unsigned block) { + struct ufs_buffer_head *ubh = UCPI_UBH(ucpi); + unsigned begin = ucpi->c_freeoff; u8 mask; switch (uspi->s_fpb) { case 8: @@ -475,9 +477,11 @@ static inline int ubh_isblockset(struct ufs_sb_private_info * uspi, return 0; } -static inline void ubh_clrblock(struct ufs_sb_private_info * uspi, - struct ufs_buffer_head * ubh, unsigned begin, unsigned block) +static inline void ubh_clrblock(struct ufs_sb_private_info *uspi, + struct ufs_cg_private_info *ucpi, unsigned block) { + struct ufs_buffer_head *ubh = UCPI_UBH(ucpi); + unsigned begin = ucpi->c_freeoff; switch (uspi->s_fpb) { case 8: *ubh_get_addr (ubh, begin + block) = 0x00; @@ -495,8 +499,10 @@ static inline void ubh_clrblock(struct ufs_sb_private_info * uspi, } static inline void ubh_setblock(struct ufs_sb_private_info * uspi, - struct ufs_buffer_head * ubh, unsigned begin, unsigned block) + struct ufs_cg_private_info *ucpi, unsigned block) { + struct ufs_buffer_head *ubh = UCPI_UBH(ucpi); + unsigned begin = ucpi->c_freeoff; switch (uspi->s_fpb) { case 8: *ubh_get_addr(ubh, begin + block) = 0xff; From patchwork Fri Oct 18 23:19:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842483 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 E4A30190075 for ; Fri, 18 Oct 2024 23:19:18 +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=1729293561; cv=none; b=u3Qa6MmBbrQkDlKLumDVNFqH7HVhGDSo8Vk9TeFGNBqiHcrgEN+mT8lQd3tCL2YgwrTeXCseiezVvmS33WCP0kQ1cu3HroVFO6KDrEmx9m4yeGiA0an7WpzNJ28Dbo0CA7rAfrdsgBaR6a2san0qXfZ27ruKl3Ih6cNY9S8rXG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293561; c=relaxed/simple; bh=oHI06Ef7DuHMnQqXn8oti1fQJix3NS7BoFW99d0Dl5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u0C6QMNIJ8ReTUwdnbuxgkb4Y4QB7RHMuvfPns+MPQQ1oO1gY9XlQtzXSCNvoSaNVXeMUl/6SLaU/q7uFDvw0+088/rv1Pjmrhw2WHeSqih16jaMB6+ZySUbmSzPzLsqGblL4RDvoDewqZzFtanXt4247cFcSnuLjJk+XeFDO+Y= 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=Fmg4tNo+; 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="Fmg4tNo+" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=esmyTWgXte12JiQAycTnydBVMov49q4rLLuz+63PTQA=; b=Fmg4tNo+u/BPkyMZbwqURVjcgc JXQuRibjbMqWxObZndl/drRF9tYxfd6/kv8e2pQbSG6oRpAMm5CkyN8awLs6hGI4Eb+vB3mUC+Rjt JtoCWmmP/xMjMMNp8zHg09puMzXjmnNJyPibIcrN5sRRd4e78+hHrglvFy2qW5cHwPEhdM8XIKf7/ kIdtMtqM0mCsMU8EiJUloAiZG8wsdGBLdDFniVWQ7gSaQCWNu3/P1U3G09sp9Yk1P/HOFMUEQPKtX lpad0JjPVHHW9FMguwEt/2R7t/F55gi68mJLPB8M1ukqHmq78DvUT1VlrKmpiw+fmtoPpmSGWG+el MNgYNppA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E6f-1XON; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 06/17] ufs: untangle ubh_...block...(), part 3 Date: Sat, 19 Oct 2024 00:19:05 +0100 Message-ID: <20241018231916.1245836-6-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro Pass fragment number instead of a block one. It's available in all callers and it makes the logics inside those helpers much simpler. The bitmap they operate upon is with bit per fragment, block being an aligned group of 1, 2, 4 or 8 adjacent fragments. We still need a switch by the number of fragments in block (== number of bits to check/set/clear), but finding the byte we need to work with becomes uniform and that makes the things easier to follow. Signed-off-by: Al Viro --- fs/ufs/balloc.c | 10 +++++----- fs/ufs/util.h | 45 ++++++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index d76c04fbd4fa..7694666fac18 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -95,7 +95,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) * Trying to reassemble free fragments into block */ blkno = ufs_fragstoblks (bbase); - if (ubh_isblockset(uspi, ucpi, blkno)) { + if (ubh_isblockset(uspi, ucpi, bbase)) { fs32_sub(sb, &ucg->cg_cs.cs_nffree, uspi->s_fpb); uspi->cs_total.cs_nffree -= uspi->s_fpb; fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, uspi->s_fpb); @@ -182,10 +182,10 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count) for (i = bit; i < end_bit; i += uspi->s_fpb) { blkno = ufs_fragstoblks(i); - if (ubh_isblockset(uspi, ucpi, blkno)) { + if (ubh_isblockset(uspi, ucpi, i)) { ufs_error(sb, "ufs_free_blocks", "freeing free fragment"); } - ubh_setblock(uspi, ucpi, blkno); + ubh_setblock(uspi, ucpi, i); inode_sub_bytes(inode, uspi->s_fpb << uspi->s_fshift); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) ufs_clusteracct (sb, ucpi, blkno, 1); @@ -716,7 +716,7 @@ static u64 ufs_alloccg_block(struct inode *inode, /* * If the requested block is available, use it. */ - if (ubh_isblockset(uspi, ucpi, ufs_fragstoblks(goal))) { + if (ubh_isblockset(uspi, ucpi, goal)) { result = goal; goto gotit; } @@ -730,7 +730,7 @@ static u64 ufs_alloccg_block(struct inode *inode, if (!try_add_frags(inode, uspi->s_fpb)) return 0; blkno = ufs_fragstoblks(result); - ubh_clrblock(uspi, ucpi, blkno); + ubh_clrblock(uspi, ucpi, result); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) ufs_clusteracct (sb, ucpi, blkno, -1); diff --git a/fs/ufs/util.h b/fs/ufs/util.h index c7196a81fb0d..fafae166ee55 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h @@ -456,65 +456,68 @@ static inline unsigned _ubh_find_last_zero_bit_( } static inline int ubh_isblockset(struct ufs_sb_private_info *uspi, - struct ufs_cg_private_info *ucpi, unsigned block) + struct ufs_cg_private_info *ucpi, unsigned int frag) { struct ufs_buffer_head *ubh = UCPI_UBH(ucpi); - unsigned begin = ucpi->c_freeoff; + u8 *p = ubh_get_addr(ubh, ucpi->c_freeoff + (frag >> 3)); u8 mask; + switch (uspi->s_fpb) { case 8: - return (*ubh_get_addr (ubh, begin + block) == 0xff); + return *p == 0xff; case 4: - mask = 0x0f << ((block & 0x01) << 2); - return (*ubh_get_addr (ubh, begin + (block >> 1)) & mask) == mask; + mask = 0x0f << (frag & 4); + return (*p & mask) == mask; case 2: - mask = 0x03 << ((block & 0x03) << 1); - return (*ubh_get_addr (ubh, begin + (block >> 2)) & mask) == mask; + mask = 0x03 << (frag & 6); + return (*p & mask) == mask; case 1: - mask = 0x01 << (block & 0x07); - return (*ubh_get_addr (ubh, begin + (block >> 3)) & mask) == mask; + mask = 0x01 << (frag & 7); + return (*p & mask) == mask; } return 0; } static inline void ubh_clrblock(struct ufs_sb_private_info *uspi, - struct ufs_cg_private_info *ucpi, unsigned block) + struct ufs_cg_private_info *ucpi, unsigned int frag) { struct ufs_buffer_head *ubh = UCPI_UBH(ucpi); - unsigned begin = ucpi->c_freeoff; + u8 *p = ubh_get_addr(ubh, ucpi->c_freeoff + (frag >> 3)); + switch (uspi->s_fpb) { case 8: - *ubh_get_addr (ubh, begin + block) = 0x00; + *p = 0x00; return; case 4: - *ubh_get_addr (ubh, begin + (block >> 1)) &= ~(0x0f << ((block & 0x01) << 2)); + *p &= ~(0x0f << (frag & 4)); return; case 2: - *ubh_get_addr (ubh, begin + (block >> 2)) &= ~(0x03 << ((block & 0x03) << 1)); + *p &= ~(0x03 << (frag & 6)); return; case 1: - *ubh_get_addr (ubh, begin + (block >> 3)) &= ~(0x01 << ((block & 0x07))); + *p &= ~(0x01 << (frag & 7)); return; } } static inline void ubh_setblock(struct ufs_sb_private_info * uspi, - struct ufs_cg_private_info *ucpi, unsigned block) + struct ufs_cg_private_info *ucpi, unsigned int frag) { struct ufs_buffer_head *ubh = UCPI_UBH(ucpi); - unsigned begin = ucpi->c_freeoff; + u8 *p = ubh_get_addr(ubh, ucpi->c_freeoff + (frag >> 3)); + switch (uspi->s_fpb) { case 8: - *ubh_get_addr(ubh, begin + block) = 0xff; + *p = 0xff; return; case 4: - *ubh_get_addr(ubh, begin + (block >> 1)) |= (0x0f << ((block & 0x01) << 2)); + *p |= 0x0f << (frag & 4); return; case 2: - *ubh_get_addr(ubh, begin + (block >> 2)) |= (0x03 << ((block & 0x03) << 1)); + *p |= 0x03 << (frag & 6); return; case 1: - *ubh_get_addr(ubh, begin + (block >> 3)) |= (0x01 << ((block & 0x07))); + *p |= 0x01 << (frag & 7); return; } } From patchwork Fri Oct 18 23:19:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842479 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 E22EC18FDD0 for ; Fri, 18 Oct 2024 23:19:18 +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=1729293560; cv=none; b=JSeYriMc62jTSqRmZi0/r3GDwnLD7g2T+tEYiAoBH/85oWI8UbCqZVj9xiw8H+5hcco6sy8ucrTBdQ05ScuCMO8S19gwDGpQ975D7cDr0qPd87XJDJcV3bIfIX+Xqq/Bc8l79+xMKql8tsei9B9tXDVmdA1ySEysOFwlkU/ei/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293560; c=relaxed/simple; bh=LVL1SIFsrRb3myZu7jZVuO4YtYbDRR9fVyesr0H6z6Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rhot52Ezmiu9Yy3hsmfL0jGunbonw2lVQh0GOyq7WK+vXTuskWG5aHvvhgUwWpDNaEScyMKdLjV1Pzv6hjyWSA6wYl2Wi4Bc5jdiol6KyuICmapfXXh+lQqekYp/kEQnImbrtUTNQg9dTSCw40QculTKROCVcpQZm1IahiF+GiE= 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=Qsc8nfQS; 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="Qsc8nfQS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=FbKNCmg51RM/Chun+chAXCK0MwTsqATxRI8ATuhBYjw=; b=Qsc8nfQS2jv2mTJGh2DGJSFP5E yhdjzB8ROBI7Yz/vbkEQPIpDDPUoAJPdILCa6vJ7cgvOOsN9uDOl1g+EZ9uPfqnhNNEe7Q8g/8Y5y yrCb9/QL/YX9yX7cGQPgDfeccG6cstJxzF557LRvpCI602qfZQ7+3xMcUPIXO3uIoNgfrjSZCRtPF zosalo8gOPfFzHQ5x8K2H15QpLhZhQrvyxt+5glVHCs73m0wNTR3ZPHlUY8cBR8TTqyRUro0btkTV IetF5SiGRdlb2lziMfjHXEMFz6FxFykKHOwFA6gZWI3KkIHdBe8uRse7hWRJK7Ohma5dLJo04avT4 KIwh6sYg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E6l-1tm1; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 07/17] ufs_clusteracct(): switch to passing fragment number Date: Sat, 19 Oct 2024 00:19:06 +0100 Message-ID: <20241018231916.1245836-7-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro Currently all callers pass it a block number. All of them have it derived from a fragment number (both fragment and block numbers are within a cylinder group, and thus 32bit). Pass it the fragment number instead; none of the callers has other uses for the block number, so that ends up with cleaner code. Signed-off-by: Al Viro --- fs/ufs/balloc.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index 7694666fac18..1793ce48df0a 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -43,7 +43,6 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) struct ufs_cg_private_info * ucpi; struct ufs_cylinder_group * ucg; unsigned cgno, bit, end_bit, bbase, blkmap, i; - u64 blkno; sb = inode->i_sb; uspi = UFS_SB(sb)->s_uspi; @@ -94,13 +93,12 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) /* * Trying to reassemble free fragments into block */ - blkno = ufs_fragstoblks (bbase); if (ubh_isblockset(uspi, ucpi, bbase)) { fs32_sub(sb, &ucg->cg_cs.cs_nffree, uspi->s_fpb); uspi->cs_total.cs_nffree -= uspi->s_fpb; fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, uspi->s_fpb); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) - ufs_clusteracct (sb, ucpi, blkno, 1); + ufs_clusteracct(sb, ucpi, bbase, 1); fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1); uspi->cs_total.cs_nbfree++; fs32_add(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nbfree, 1); @@ -139,7 +137,6 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count) struct ufs_cg_private_info * ucpi; struct ufs_cylinder_group * ucg; unsigned overflow, cgno, bit, end_bit, i; - u64 blkno; sb = inode->i_sb; uspi = UFS_SB(sb)->s_uspi; @@ -181,14 +178,13 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count) } for (i = bit; i < end_bit; i += uspi->s_fpb) { - blkno = ufs_fragstoblks(i); if (ubh_isblockset(uspi, ucpi, i)) { ufs_error(sb, "ufs_free_blocks", "freeing free fragment"); } ubh_setblock(uspi, ucpi, i); inode_sub_bytes(inode, uspi->s_fpb << uspi->s_fshift); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) - ufs_clusteracct (sb, ucpi, blkno, 1); + ufs_clusteracct(sb, ucpi, i, 1); fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1); uspi->cs_total.cs_nbfree++; @@ -698,7 +694,7 @@ static u64 ufs_alloccg_block(struct inode *inode, struct super_block * sb; struct ufs_sb_private_info * uspi; struct ufs_cylinder_group * ucg; - u64 result, blkno; + u64 result; UFSD("ENTER, goal %llu\n", (unsigned long long)goal); @@ -729,10 +725,9 @@ static u64 ufs_alloccg_block(struct inode *inode, gotit: if (!try_add_frags(inode, uspi->s_fpb)) return 0; - blkno = ufs_fragstoblks(result); ubh_clrblock(uspi, ucpi, result); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) - ufs_clusteracct (sb, ucpi, blkno, -1); + ufs_clusteracct(sb, ucpi, result, -1); fs32_sub(sb, &ucg->cg_cs.cs_nbfree, 1); uspi->cs_total.cs_nbfree--; @@ -863,12 +858,12 @@ static u64 ufs_bitmap_search(struct super_block *sb, } static void ufs_clusteracct(struct super_block * sb, - struct ufs_cg_private_info * ucpi, unsigned blkno, int cnt) + struct ufs_cg_private_info * ucpi, unsigned frag, int cnt) { - struct ufs_sb_private_info * uspi; + struct ufs_sb_private_info * uspi = UFS_SB(sb)->s_uspi; int i, start, end, forw, back; + unsigned blkno = ufs_fragstoblks(frag); - uspi = UFS_SB(sb)->s_uspi; if (uspi->s_contigsumsize <= 0) return; From patchwork Fri Oct 18 23:19: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: 13842478 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 E86FF19046E for ; Fri, 18 Oct 2024 23:19:18 +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=1729293560; cv=none; b=ndc5KfQmFEWG8lolTw7DF49/zL+/xWu2qVg6AuH6zD83K30nbnr5+pSLOhqGRq41Pzck9HFZZUQLtAOCfeqVtd6pUQdHvPbnBuWyhuvey3PZK5A7ifczeKK/sxYdMRI1O4ZUfk8gbVYacDpiYh7yzlz0bCdK5/RPQXCKCBeEz04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293560; c=relaxed/simple; bh=ILu5roTMNLi30ZqlLLov+pkCcbdUgQBjejjHjQ6Y8AM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ciSxW8JPlAMIY2tV6+XCB5TVsBi0xyT9EmPYTgtg9sOoEA2O9sw5ezCcI2QPUU+MOKu+jKFQ85GTGizHEfIfzSych16/Z8+w9soKpi5WXGyQ2P7VvWRkJ7vSgI+6vWZC867emJb1zgTKvJWsz95L//lCK9ctoYWZ6Twx63COioA= 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=ZaX8zxY/; 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="ZaX8zxY/" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=nEtg1G+606pABvYVMrrr0iQEdhjJjDd/e26fl/qwRTY=; b=ZaX8zxY/MG6/TH5t1E24UWgGJx FJAdUwo2JnE/Q03evyktRFPCpnhkTJ2w991a/U7evtgNnELwb/i/Y1WHkUzdP47ZNfJmPQEpZeMTY EbVBHGbnL7TiL242sn9d5HVxgZsCY8lExGdvzc27lbzhLYeHJ9i7+BGPRfTf1wDYTKCcb/BG03D4D QwNZlKxJxQhuGdyveBpbT5RgPKv5YUjV4HsN19h1HcQ8LoHIJeoNYpsFY5+D2E8kvK3NtuWgCs5rz pZcY0yWOpfAscHtgEfL3k2g9xXVussjqTLs6qRGqoCtytjraMiHU/hwHkOk/CpGZFRVs2eE0HDUL5 b7aWFQHA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E6r-2DVh; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 08/17] ufs_free_fragments(): fix the braino in sanity check Date: Sat, 19 Oct 2024 00:19:07 +0100 Message-ID: <20241018231916.1245836-8-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro The function expects that all fragments it's been asked to free will be within the same block. And it even has a sanity check verifying that - it takes the fragment number modulo the number of fragments per block, adds the count and checks if that's too high. Unfortunately, it misspells the upper limit - instead of ->s_fpb (fragments per block) it says ->s_fpg (fragments per cylinder group). So "too high" ends up being insanely lenient. Had been that way since 2.1.112, when UFS write support had been added. 27 years to spot a typo... Signed-off-by: Al Viro --- fs/ufs/balloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index 1793ce48df0a..82f1a4a128a2 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -50,7 +50,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) UFSD("ENTER, fragment %llu, count %u\n", (unsigned long long)fragment, count); - if (ufs_fragnum(fragment) + count > uspi->s_fpg) + if (ufs_fragnum(fragment) + count > uspi->s_fpb) ufs_error (sb, "ufs_free_fragments", "internal error"); mutex_lock(&UFS_SB(sb)->s_lock); From patchwork Fri Oct 18 23:19:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842480 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 248AF19049B for ; Fri, 18 Oct 2024 23:19:18 +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=1729293560; cv=none; b=bI0t9g0nJX6dLIhcSGYow84U+4v4zndFFA5dRN9evgmJkg3wppNKuIKRNlGsHE2SVW+D4LSTQ6EbL+C4YorATkbZr7c8BCqMPNDLUqiImFw8oNLpSYWtxmumS5z4vneCXxF9owl1N9AcPnse9q/4zcuBwSEacT4G7TuQHdzuEVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293560; c=relaxed/simple; bh=SEpZ/Iz/JJNcmEV7HnF8Fc0cfRkUwkzMTwJmKWSVB5I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tr05VPnp3PcD0lJ+AYyAGr7u5iFoZTdD5aE6FHub3hHHTmx7022qds4L1WWN+rsSQ+JCVIRo8rtUobPYHnDHGgF8btG5GqbATbpXz8K1OrWTMRj2b0R7uidhussforOnogzzZZYfrZU4lXeOQPYokj7YgT0XhRNmIYB4r/ctqg4= 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=JDTdFaIV; 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="JDTdFaIV" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=rWGCxxFoeLTcVseiekGh5/SBzG4ZPNhsNx2ql0KvaGg=; b=JDTdFaIVYd0ZxSXrsegknxWTtE vI85sxj5Q2DdNE+DPnmS+rNEoBH/NDMmoiPztMg/L4LHZXl8CbwAK0zXPATQduq9L64MheDRfzo3h tsimL0Ai5LUaqc0xZBozF0kTYvcLCJ99QKUuQOvmE8ZX3UwjR8cYpctzOwYjE1zJmUaQ2ukqKM4gp IA9TzGEOeWphNU5lfPctQkEkCjvuwgA+tugvWHqb7dmKpbProF/kOyVvlZb8tmRPaFNLP8e++BAPD rWHO6Cvvjb9VDwqzAiKE+TTCKd0YHlddlm5+kQz4yNwJY5IDe0BELi0y/eiaUmXEQrwwlqRkcGcX4 qXbJzNhA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E6y-2T4M; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 09/17] ufs_inode_getfrag(): remove junk comment Date: Sat, 19 Oct 2024 00:19:08 +0100 Message-ID: <20241018231916.1245836-9-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro It used to be a stubbed out beginning of ufs2 support, which had been implemented differently quite a while ago. Remove the commented-out (pseudo-)code. Signed-off-by: Al Viro --- fs/ufs/inode.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 5331ae7ebf3e..71d28561200f 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -264,11 +264,6 @@ ufs_inode_getfrag(struct inode *inode, unsigned index, unsigned nfrags = uspi->s_fpb; void *p; - /* TODO : to be done for write support - if ( (flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) - goto ufs2; - */ - p = ufs_get_direct_data_ptr(uspi, ufsi, index); tmp = ufs_data_ptr_to_cpu(sb, p); if (tmp) @@ -303,21 +298,6 @@ ufs_inode_getfrag(struct inode *inode, unsigned index, mark_inode_dirty(inode); out: return tmp + uspi->s_sbbase; - - /* This part : To be implemented .... - Required only for writing, not required for READ-ONLY. -ufs2: - - u2_block = ufs_fragstoblks(fragment); - u2_blockoff = ufs_fragnum(fragment); - p = ufsi->i_u1.u2_i_data + block; - goal = 0; - -repeat2: - tmp = fs32_to_cpu(sb, *p); - lastfrag = ufsi->i_lastfrag; - - */ } /** From patchwork Fri Oct 18 23:19:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842492 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 94B78190676 for ; Fri, 18 Oct 2024 23:19:19 +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=1729293563; cv=none; b=URMKX0YsL5Hza71PhzSOH/LUHkBETsGBetvV5qDTV+6rln0S8d6Tl31kH3Kqawe5dEQryORDsyonPVchTRoLqlBRLLwQhepN755TobcgppWKBt5y7ds1lPe2E2JJDY6PkGF2wx6AMQR7oTO6xgpzYdbnq9WjKiMgtuM5qH7lzFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293563; c=relaxed/simple; bh=ncS2EwebJwVkIBvupJsgGEkc2PgIQxYVHfAHcAH5kFc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a3QovUviVh202SBdq/RHuU7osHnZOctkX9vgJLobxyKzTxmHfBuWAKCPvR0JQSagfY2rby58U7O9z1VS/SVN6fx6qpNSPIivB4DKE13saD0TS/fWyiOH+Ure+C8D0VWzsap9LytYwit0VqJud+rGDmzJ1Nhf42vlYgQFpWy7nQI= 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=MrvNEuV9; 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="MrvNEuV9" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=L3yvI0PxQV2PHgIYlSEX8bt8DFBuH9lu+yPBoVKvTW0=; b=MrvNEuV9mJ5G81eAhVeUVAb3AU yVVGOV/L5ylVtY3X6KC4Um6n+MOc7tnnaVGA3wDKJi82Q2zf3ajilThaRXS4/8E47RIg/URVMClNJ YvMlHvzbcw08LfNPyane4dSxEC8ENSLXXYjlyZCIfn2piAivOUQ7Wc6Ib1DN42yVNQtRGwjEcVYhd 1QEM/RoLEkC9wrI2bRe+dvLyiGfz7sp0NSf3aanAl/joZk/Sy43sszrM5FHmk9wgpsDb3y4cq2PNZ t25p/xXXAjzk8F+ov1fVqNk44zlnuD4DWneVe3D2x96Mwbh0nIkMU/4B1M85rwrqkpZPkRd06JCN1 BWeKVfVg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E74-2s4z; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 10/17] ufs: get rid of ubh_{ubhcpymem,memcpyubh}() Date: Sat, 19 Oct 2024 00:19:09 +0100 Message-ID: <20241018231916.1245836-10-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro used only in ufs_read_cylinder_structures()/ufs_put_super_internal() and there we can just as well avoid bothering with ufs_buffer_head and just deal with it fragment-by-fragment. Signed-off-by: Al Viro --- fs/ufs/super.c | 45 +++++++++++++++++---------------------------- fs/ufs/util.c | 46 ---------------------------------------------- fs/ufs/util.h | 5 ----- 3 files changed, 17 insertions(+), 79 deletions(-) diff --git a/fs/ufs/super.c b/fs/ufs/super.c index bc625788589c..e876c60e70ea 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -505,7 +505,6 @@ static int ufs_read_cylinder_structures(struct super_block *sb) { struct ufs_sb_info *sbi = UFS_SB(sb); struct ufs_sb_private_info *uspi = sbi->s_uspi; - struct ufs_buffer_head * ubh; unsigned char * base, * space; unsigned size, blks, i; @@ -521,21 +520,13 @@ static int ufs_read_cylinder_structures(struct super_block *sb) if (!base) goto failed; sbi->s_csp = (struct ufs_csum *)space; - for (i = 0; i < blks; i += uspi->s_fpb) { - size = uspi->s_bsize; - if (i + uspi->s_fpb > blks) - size = (blks - i) * uspi->s_fsize; - - ubh = ubh_bread(sb, uspi->s_csaddr + i, size); - - if (!ubh) + for (i = 0; i < blks; i++) { + struct buffer_head *bh = sb_bread(sb, uspi->s_csaddr + i); + if (!bh) goto failed; - - ubh_ubhcpymem (space, ubh, size); - - space += size; - ubh_brelse (ubh); - ubh = NULL; + memcpy(space, bh->b_data, uspi->s_fsize); + space += uspi->s_fsize; + brelse (bh); } /* @@ -645,7 +636,6 @@ static void ufs_put_super_internal(struct super_block *sb) { struct ufs_sb_info *sbi = UFS_SB(sb); struct ufs_sb_private_info *uspi = sbi->s_uspi; - struct ufs_buffer_head * ubh; unsigned char * base, * space; unsigned blks, size, i; @@ -656,18 +646,17 @@ static void ufs_put_super_internal(struct super_block *sb) size = uspi->s_cssize; blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift; base = space = (char*) sbi->s_csp; - for (i = 0; i < blks; i += uspi->s_fpb) { - size = uspi->s_bsize; - if (i + uspi->s_fpb > blks) - size = (blks - i) * uspi->s_fsize; - - ubh = ubh_bread(sb, uspi->s_csaddr + i, size); - - ubh_memcpyubh (ubh, space, size); - space += size; - ubh_mark_buffer_uptodate (ubh, 1); - ubh_mark_buffer_dirty (ubh); - ubh_brelse (ubh); + for (i = 0; i < blks; i++, space += uspi->s_fsize) { + struct buffer_head *bh = sb_bread(sb, uspi->s_csaddr + i); + + if (unlikely(!bh)) { // better than an oops... + ufs_panic(sb, __func__, + "can't write part of cylinder group summary"); + continue; + } + memcpy(bh->b_data, space, uspi->s_fsize); + mark_buffer_dirty(bh); + brelse(bh); } for (i = 0; i < sbi->s_cg_loaded; i++) { ufs_put_cylinder (sb, i); diff --git a/fs/ufs/util.c b/fs/ufs/util.c index 2acf191eb89e..f0e906ab4ddd 100644 --- a/fs/ufs/util.c +++ b/fs/ufs/util.c @@ -99,20 +99,6 @@ void ubh_mark_buffer_dirty (struct ufs_buffer_head * ubh) mark_buffer_dirty (ubh->bh[i]); } -void ubh_mark_buffer_uptodate (struct ufs_buffer_head * ubh, int flag) -{ - unsigned i; - if (!ubh) - return; - if (flag) { - for ( i = 0; i < ubh->count; i++ ) - set_buffer_uptodate (ubh->bh[i]); - } else { - for ( i = 0; i < ubh->count; i++ ) - clear_buffer_uptodate (ubh->bh[i]); - } -} - void ubh_sync_block(struct ufs_buffer_head *ubh) { if (ubh) { @@ -146,38 +132,6 @@ int ubh_buffer_dirty (struct ufs_buffer_head * ubh) return result; } -void _ubh_ubhcpymem_(struct ufs_sb_private_info * uspi, - unsigned char * mem, struct ufs_buffer_head * ubh, unsigned size) -{ - unsigned len, bhno; - if (size > (ubh->count << uspi->s_fshift)) - size = ubh->count << uspi->s_fshift; - bhno = 0; - while (size) { - len = min_t(unsigned int, size, uspi->s_fsize); - memcpy (mem, ubh->bh[bhno]->b_data, len); - mem += uspi->s_fsize; - size -= len; - bhno++; - } -} - -void _ubh_memcpyubh_(struct ufs_sb_private_info * uspi, - struct ufs_buffer_head * ubh, unsigned char * mem, unsigned size) -{ - unsigned len, bhno; - if (size > (ubh->count << uspi->s_fshift)) - size = ubh->count << uspi->s_fshift; - bhno = 0; - while (size) { - len = min_t(unsigned int, size, uspi->s_fsize); - memcpy (ubh->bh[bhno]->b_data, mem, len); - mem += uspi->s_fsize; - size -= len; - bhno++; - } -} - dev_t ufs_get_inode_dev(struct super_block *sb, struct ufs_inode_info *ufsi) { diff --git a/fs/ufs/util.h b/fs/ufs/util.h index fafae166ee55..391bb4f11d74 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h @@ -263,14 +263,9 @@ extern struct ufs_buffer_head * ubh_bread_uspi(struct ufs_sb_private_info *, str extern void ubh_brelse (struct ufs_buffer_head *); extern void ubh_brelse_uspi (struct ufs_sb_private_info *); extern void ubh_mark_buffer_dirty (struct ufs_buffer_head *); -extern void ubh_mark_buffer_uptodate (struct ufs_buffer_head *, int); extern void ubh_sync_block(struct ufs_buffer_head *); extern void ubh_bforget (struct ufs_buffer_head *); extern int ubh_buffer_dirty (struct ufs_buffer_head *); -#define ubh_ubhcpymem(mem,ubh,size) _ubh_ubhcpymem_(uspi,mem,ubh,size) -extern void _ubh_ubhcpymem_(struct ufs_sb_private_info *, unsigned char *, struct ufs_buffer_head *, unsigned); -#define ubh_memcpyubh(ubh,mem,size) _ubh_memcpyubh_(uspi,ubh,mem,size) -extern void _ubh_memcpyubh_(struct ufs_sb_private_info *, struct ufs_buffer_head *, unsigned char *, unsigned); /* This functions works with cache pages*/ struct folio *ufs_get_locked_folio(struct address_space *mapping, pgoff_t index); From patchwork Fri Oct 18 23:19:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842493 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 9615819067C for ; Fri, 18 Oct 2024 23:19:19 +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=1729293563; cv=none; b=FRIoaDME6ui+bLXehguZ7DfEPJXS4/FrPlSVHLQsK6DvVBdTAiqcs6TKALp5C6Mm9uC0hWEy2jPPZWwTIA83X5nB+3j/XoRoiyJccoBr0jSQMqvaYVjNXnZTc4XJcxLHQaYn0OQ+g30YJry0LYZwCdiuXDyKnBvtWcwujKqfXUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293563; c=relaxed/simple; bh=Ru7q1KUURm+W0WgriK939NckPsDn7izxaLYEvS43nh8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K06ltuHINZHFtPr6KnzquMaSvqLndDoHp0Xxuox7ZurxCf0CJUWdTWoyb50ggRALME/NvDv2PUsCENjE9LLPMuaxO/NfRjqwCneBPozu22Pdq1FgTYiDQmvXHtV3XhsqN48EOahEGCNa7bQPJS+paSu1W3p/1DxkdjGxfe0wswo= 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=JNnQIEEC; 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="JNnQIEEC" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=iHQl9M43iBnscOh6V3WkPFb0AzB91bu+xcFwPk3E4Fs=; b=JNnQIEECCFRmSEgSzU57k3KHI/ STVwtOmVTUXzSzQCLwMGkt9pBmGbsdeDaldPBABEZlixI9oe8zKULEBzX35lzZu39TYl6uB3fHkHn 9u16B9p4czUhMhl4qEpmbGtGOfeNqre0wZDVDhG3iqyXefzJqDf+enwk4r+kObKkp+SdfAtlsVZQ7 O3BqjDvX7i/fOreQ8aMvzOb3SF+gAoOSlVAzEPmk+rpo1Fu4nA330xgSI5f/3GXCOVXugQYTM7t2/ QBeHUx3tIbnlfEv1wQmMvVbyLnYEwOyG+a3S+R5IFvGUbLtCqUv8QYQMuZD2lf1YwhEOoUWSeBZJi mLBJhpjg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E7A-3FO2; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 11/17] clean ufs_trunc_direct() up a bit... Date: Sat, 19 Oct 2024 00:19:10 +0100 Message-ID: <20241018231916.1245836-11-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro For short files (== no indirect blocks needed) UFS allows the last block to be a partial one. That creates some complications for truncation down to "short file" lengths. ufs_trunc_direct() is called when we'd already made sure that new EOF is not in a hole; nothing needs to be done if we are extending the file and in case we are shrinking the file it needs to * shrink or free the old final block. * free all full direct blocks between the new and old EOF. * possibly shrink the new final block. The logics is needlessly complicated by trying to keep all cases handled by the same sequence of operations. if not shrinking nothing to do else if number of full blocks unchanged free the tail of possibly partial last block else free the tail of (currently full) new last block free all present (full) blocks in between free the (possibly partial) old last block is easier to follow than the result of trying to unify these cases. Signed-off-by: Al Viro --- fs/ufs/inode.c | 129 +++++++++++++++++++++++-------------------------- 1 file changed, 61 insertions(+), 68 deletions(-) diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 71d28561200f..a3475afb3c26 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -878,91 +878,84 @@ static inline void free_data(struct to_free *ctx, u64 from, unsigned count) #define DIRECT_FRAGMENT ((inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift) +/* + * used only for truncation down to direct blocks. + */ static void ufs_trunc_direct(struct inode *inode) { struct ufs_inode_info *ufsi = UFS_I(inode); - struct super_block * sb; - struct ufs_sb_private_info * uspi; - void *p; - u64 frag1, frag2, frag3, frag4, block1, block2; + struct super_block *sb = inode->i_sb; + struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; + unsigned int new_frags, old_frags; + unsigned int old_slot, new_slot; + unsigned int old_tail, new_tail; struct to_free ctx = {.inode = inode}; - unsigned i, tmp; UFSD("ENTER: ino %lu\n", inode->i_ino); - sb = inode->i_sb; - uspi = UFS_SB(sb)->s_uspi; - - frag1 = DIRECT_FRAGMENT; - frag4 = min_t(u64, UFS_NDIR_FRAGMENT, ufsi->i_lastfrag); - frag2 = ((frag1 & uspi->s_fpbmask) ? ((frag1 | uspi->s_fpbmask) + 1) : frag1); - frag3 = frag4 & ~uspi->s_fpbmask; - block1 = block2 = 0; - if (frag2 > frag3) { - frag2 = frag4; - frag3 = frag4 = 0; - } else if (frag2 < frag3) { - block1 = ufs_fragstoblks (frag2); - block2 = ufs_fragstoblks (frag3); - } - - UFSD("ino %lu, frag1 %llu, frag2 %llu, block1 %llu, block2 %llu," - " frag3 %llu, frag4 %llu\n", inode->i_ino, - (unsigned long long)frag1, (unsigned long long)frag2, - (unsigned long long)block1, (unsigned long long)block2, - (unsigned long long)frag3, (unsigned long long)frag4); + new_frags = DIRECT_FRAGMENT; + // new_frags = first fragment past the new EOF + old_frags = min_t(u64, UFS_NDIR_FRAGMENT, ufsi->i_lastfrag); + // old_frags = first fragment past the old EOF or covered by indirects - if (frag1 >= frag2) - goto next1; - - /* - * Free first free fragments - */ - p = ufs_get_direct_data_ptr(uspi, ufsi, ufs_fragstoblks(frag1)); - tmp = ufs_data_ptr_to_cpu(sb, p); - if (!tmp ) - ufs_panic (sb, "ufs_trunc_direct", "internal error"); - frag2 -= frag1; - frag1 = ufs_fragnum (frag1); + if (new_frags >= old_frags) // expanding - nothing to free + goto done; - ufs_free_fragments(inode, tmp + frag1, frag2); + old_tail = ufs_fragnum(old_frags); + old_slot = ufs_fragstoblks(old_frags); + new_tail = ufs_fragnum(new_frags); + new_slot = ufs_fragstoblks(new_frags); -next1: - /* - * Free whole blocks - */ - for (i = block1 ; i < block2; i++) { - p = ufs_get_direct_data_ptr(uspi, ufsi, i); - tmp = ufs_data_ptr_to_cpu(sb, p); + if (old_slot == new_slot) { // old_tail > 0 + void *p = ufs_get_direct_data_ptr(uspi, ufsi, old_slot); + u64 tmp = ufs_data_ptr_to_cpu(sb, p); if (!tmp) - continue; - write_seqlock(&ufsi->meta_lock); - ufs_data_ptr_clear(uspi, p); - write_sequnlock(&ufsi->meta_lock); + ufs_panic(sb, __func__, "internal error"); + if (!new_tail) { + write_seqlock(&ufsi->meta_lock); + ufs_data_ptr_clear(uspi, p); + write_sequnlock(&ufsi->meta_lock); + } + ufs_free_fragments(inode, tmp + new_tail, old_tail - new_tail); + } else { + unsigned int slot = new_slot; - free_data(&ctx, tmp, uspi->s_fpb); - } + if (new_tail) { + void *p = ufs_get_direct_data_ptr(uspi, ufsi, slot++); + u64 tmp = ufs_data_ptr_to_cpu(sb, p); + if (!tmp) + ufs_panic(sb, __func__, "internal error"); - free_data(&ctx, 0, 0); + ufs_free_fragments(inode, tmp + new_tail, + uspi->s_fpb - new_tail); + } + while (slot < old_slot) { + void *p = ufs_get_direct_data_ptr(uspi, ufsi, slot++); + u64 tmp = ufs_data_ptr_to_cpu(sb, p); + if (!tmp) + continue; + write_seqlock(&ufsi->meta_lock); + ufs_data_ptr_clear(uspi, p); + write_sequnlock(&ufsi->meta_lock); - if (frag3 >= frag4) - goto next3; + free_data(&ctx, tmp, uspi->s_fpb); + } - /* - * Free last free fragments - */ - p = ufs_get_direct_data_ptr(uspi, ufsi, ufs_fragstoblks(frag3)); - tmp = ufs_data_ptr_to_cpu(sb, p); - if (!tmp ) - ufs_panic(sb, "ufs_truncate_direct", "internal error"); - frag4 = ufs_fragnum (frag4); - write_seqlock(&ufsi->meta_lock); - ufs_data_ptr_clear(uspi, p); - write_sequnlock(&ufsi->meta_lock); + free_data(&ctx, 0, 0); - ufs_free_fragments (inode, tmp, frag4); - next3: + if (old_tail) { + void *p = ufs_get_direct_data_ptr(uspi, ufsi, slot); + u64 tmp = ufs_data_ptr_to_cpu(sb, p); + if (!tmp) + ufs_panic(sb, __func__, "internal error"); + write_seqlock(&ufsi->meta_lock); + ufs_data_ptr_clear(uspi, p); + write_sequnlock(&ufsi->meta_lock); + ufs_free_fragments(inode, tmp, old_tail); + } + } +done: UFSD("EXIT: ino %lu\n", inode->i_ino); } From patchwork Fri Oct 18 23:19:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842488 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 9349C190664 for ; Fri, 18 Oct 2024 23:19:19 +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=1729293562; cv=none; b=FdJ6Q6NINZ9t4P3IzxLDz09H8UR3AuoDl19CEyBhXLnhMYqg8/OhO2fQuwJLRuZ9qQUYR+ZHHsJ/hQpixHEhxKRXui8VylRp3EiNDBJQ2eQNHrMhnOV1iwMrGLudPOxD73bjbxFgXHRuOdTHGg6PYRFT76avjEbX0GBeeZi239Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293562; c=relaxed/simple; bh=eQndQ09DAc2J8GGvQ93NPkyDtJQFhZeqP0Ulf+KbLpw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dkb2b9JtNP058BYaI/fp8zD/KhJaXIEfob+KvW/1xi1bmxu9oRKUeouaSUDZOl07jh1oG8H9DMtESluO2R5w/Hx7UkunmdrJPfoy7zCQJLNxH74+xg6LXIW2bZbxMlBJQ7guv41oX2GIETahSWCv9ef7QNCQeA4IENfnFiwR8es= 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=FRhTFX0V; 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="FRhTFX0V" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=9xxw3Kf+3TKqZMPub9ymqN2QOj3B++Fc5yMmws2tJOQ=; b=FRhTFX0VCRX/CeFYRqMStAcp/6 lFQyF/BI+iiImhcuYCcLkkf6EuRrWEKcXYSVqSqz/FfxME757oNWRU7Dqfi4F/tVXcNLAIuxJj6m2 pqCjv7eMjstII3m2Uohnjzw0/M7yAsJoqy+u0Qt5JlGB/Jq7x3UWnJSWv7zzhI11AUGPoufajHhWf Ej0zCBtJYGrDvPWXmosglIgCOz+XYiJM6UIASGSkpItr1Xk0qE5Ez8WJBDfRqEzLrVLVK6JGbeEPp BMoj6kP11XMigap8wTt8VI0Xv48ZWAiInLY0PuEu04OGYmEyyepn9X7j62+kzzGzVo24X1PSpRY64 RKPIZnCQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E7G-3cix; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 12/17] ufs: take the handling of free block counters into a helper Date: Sat, 19 Oct 2024 00:19:11 +0100 Message-ID: <20241018231916.1245836-12-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro There are 3 places where those counters (many and varied...) are adjusted - when we are freeing fragments and get an entire block freed, when we are freeing blocks and (in opposite direction) when we are grabbing a block. The logics is identical (modulo the sign of adjustment) in all three; better take it into a helper - less duplication and less clutter in the callers that way. Signed-off-by: Al Viro --- fs/ufs/balloc.c | 66 +++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index 82f1a4a128a2..c60006c5806c 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -33,6 +33,29 @@ static u64 ufs_bitmap_search (struct super_block *, struct ufs_cg_private_info * static unsigned char ufs_fragtable_8fpb[], ufs_fragtable_other[]; static void ufs_clusteracct(struct super_block *, struct ufs_cg_private_info *, unsigned, int); +static void adjust_free_blocks(struct super_block *sb, + struct ufs_cylinder_group *ucg, + struct ufs_cg_private_info *ucpi, + unsigned fragment, int delta) +{ + struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; + + if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) + ufs_clusteracct(sb, ucpi, fragment, delta); + + fs32_add(sb, &ucg->cg_cs.cs_nbfree, delta); + uspi->cs_total.cs_nbfree += delta; + fs32_add(sb, &UFS_SB(sb)->fs_cs(ucpi->c_cgx).cs_nbfree, delta); + + if (uspi->fs_magic != UFS2_MAGIC) { + unsigned cylno = ufs_cbtocylno(fragment); + + fs16_add(sb, &ubh_cg_blks(ucpi, cylno, + ufs_cbtorpos(fragment)), delta); + fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), delta); + } +} + /* * Free 'count' fragments from fragment number 'fragment' */ @@ -97,18 +120,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) fs32_sub(sb, &ucg->cg_cs.cs_nffree, uspi->s_fpb); uspi->cs_total.cs_nffree -= uspi->s_fpb; fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, uspi->s_fpb); - if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) - ufs_clusteracct(sb, ucpi, bbase, 1); - fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1); - uspi->cs_total.cs_nbfree++; - fs32_add(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nbfree, 1); - if (uspi->fs_magic != UFS2_MAGIC) { - unsigned cylno = ufs_cbtocylno (bbase); - - fs16_add(sb, &ubh_cg_blks(ucpi, cylno, - ufs_cbtorpos(bbase)), 1); - fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), 1); - } + adjust_free_blocks(sb, ucg, ucpi, bbase, 1); } ubh_mark_buffer_dirty (USPI_UBH(uspi)); @@ -183,20 +195,7 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count) } ubh_setblock(uspi, ucpi, i); inode_sub_bytes(inode, uspi->s_fpb << uspi->s_fshift); - if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) - ufs_clusteracct(sb, ucpi, i, 1); - - fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1); - uspi->cs_total.cs_nbfree++; - fs32_add(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nbfree, 1); - - if (uspi->fs_magic != UFS2_MAGIC) { - unsigned cylno = ufs_cbtocylno(i); - - fs16_add(sb, &ubh_cg_blks(ucpi, cylno, - ufs_cbtorpos(i)), 1); - fs32_add(sb, &ubh_cg_blktot(ucpi, cylno), 1); - } + adjust_free_blocks(sb, ucg, ucpi, i, 1); } ubh_mark_buffer_dirty (USPI_UBH(uspi)); @@ -726,20 +725,7 @@ static u64 ufs_alloccg_block(struct inode *inode, if (!try_add_frags(inode, uspi->s_fpb)) return 0; ubh_clrblock(uspi, ucpi, result); - if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) - ufs_clusteracct(sb, ucpi, result, -1); - - fs32_sub(sb, &ucg->cg_cs.cs_nbfree, 1); - uspi->cs_total.cs_nbfree--; - fs32_sub(sb, &UFS_SB(sb)->fs_cs(ucpi->c_cgx).cs_nbfree, 1); - - if (uspi->fs_magic != UFS2_MAGIC) { - unsigned cylno = ufs_cbtocylno((unsigned)result); - - fs16_sub(sb, &ubh_cg_blks(ucpi, cylno, - ufs_cbtorpos((unsigned)result)), 1); - fs32_sub(sb, &ubh_cg_blktot(ucpi, cylno), 1); - } + adjust_free_blocks(sb, ucg, ucpi, result, -1); UFSD("EXIT, result %llu\n", (unsigned long long)result); From patchwork Fri Oct 18 23:19:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842481 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 7E1A3190661 for ; Fri, 18 Oct 2024 23:19:19 +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=1729293561; cv=none; b=sVxLQgC4GwUDlkzadhNSMv+kfGcDNTJRfg8+m2JLXPhl54aQXJ9JkbowukXQTpUIqlnVuxzJspQPcwu8YvaLAP5SSxO/oTzcYLGzVCZO0a/8w8+oVTxp3sRs24Rwpgz5JvCU0mmqKG/O4BwVObVUWjez/PxSq2P5OPlkuRhs+lo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293561; c=relaxed/simple; bh=3JhbPFWCZ7zruMqnLJrw/Dl0q61qcTk5NyhPisNxufo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lpRYUbbcfWbFDvLppTAcDNDBuBTN7LlKhbkvxMYHFqGk5L8OyEQPZ7cGlyvOlZxP/wxhH2l69bBVFPPn0FdsPca2ohY9Jcj08NI2qwnHxAwF+ikcIi+ZGNSEA0e+nDrxojHLJquQzxuH6Y/5qbc38kMYA7W3VbkJSJwTPKUgnww= 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=uVEPmfsC; 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="uVEPmfsC" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=THIIVdGDNd8KIOhZShAVHavkP1cYo442Eq+xHAPmyeI=; b=uVEPmfsCTlJ6lCrf3GbpBq8xca hvFNZzmpA0xEvjWDZcszZBUvKpHAcjolVrAcNg3bNVOrDads9TXGI69RX3twQBsdqyD6BopkiLtc9 rCRCrp/xtg2U1XEOg817LJj40m0wU9abweGmqT6lzLa0ctDALPItD+ITBmTrjZHCxosaYJ/LOtoFR ABFrRuyhugOn/5HY1ES3g/pVIMoDHq1O/8svKUjWjofQh7eP4znWW0qH3Z9psv6CLv/pV6a8as5a/ SbhFdKfyDBInnoFPkFlgKT0Acor5vXKkGU9Gbpfz+8zqFlUbrRVm4KGWGf3tPuPyhhxIb7PSwS5/T sQcc1ZEA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFZ-00000005E7M-3zo1; Fri, 18 Oct 2024 23:19:17 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 13/17] ufs: Convert ufs_inode_getblock() to take a folio Date: Sat, 19 Oct 2024 00:19:12 +0100 Message-ID: <20241018231916.1245836-13-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro From: "Matthew Wilcox (Oracle)" Pass bh->b_folio instead of bh->b_page. They're in a union, so no code change expected. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Al Viro --- fs/ufs/inode.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index a3475afb3c26..912950ee5104 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -309,12 +309,11 @@ ufs_inode_getfrag(struct inode *inode, unsigned index, * (block will hold this fragment and also uspi->s_fpb-1) * @err: see ufs_inode_getfrag() * @new: see ufs_inode_getfrag() - * @locked_page: see ufs_inode_getfrag() + * @locked_folio: see ufs_inode_getfrag() */ -static u64 -ufs_inode_getblock(struct inode *inode, u64 ind_block, - unsigned index, sector_t new_fragment, int *err, - int *new, struct page *locked_page) +static u64 ufs_inode_getblock(struct inode *inode, u64 ind_block, + unsigned index, sector_t new_fragment, int *err, + int *new, struct folio *locked_folio) { struct super_block *sb = inode->i_sb; struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; @@ -349,7 +348,7 @@ ufs_inode_getblock(struct inode *inode, u64 ind_block, else goal = bh->b_blocknr + uspi->s_fpb; tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), goal, - uspi->s_fpb, err, locked_page); + uspi->s_fpb, err, &locked_folio->page); if (!tmp) goto out; @@ -430,7 +429,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff phys64 = ufs_inode_getblock(inode, phys64, offsets[i], fragment, &err, NULL, NULL); phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 1], - fragment, &err, &new, bh_result->b_page); + fragment, &err, &new, bh_result->b_folio); } out: if (phys64) { From patchwork Fri Oct 18 23:19: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: 13842486 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 97759191461 for ; Fri, 18 Oct 2024 23:19:19 +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=1729293561; cv=none; b=s9v5txT+Wmn36P+lgZ1zJHaDJrXXVYZeln9ZoDurpSVjtDHDB1DIalQj1UPEI1eY7SIV3iJTu7L2Ys64Erx6DaCl9jjyVL+ROnqhEDoF4a+dYJto6RfsdOj5kCdF5bOgjVmCHubgmCah6B5xKlGC/uZ0yiE+BlK+Jm+sA6WOCgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293561; c=relaxed/simple; bh=mytbpyeqKwdMhJ9ze1E9vBj9e7GeXaS4wu2USFlfE3c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o8nJn3UWCKU9HUdYzLBmEQesj7EV+/i9GGZu482Eyi1f/6LG6QEoOH84+BYqD9j0MXhndWmMCmPF4EBTIVGi0awVVMBhAnec1DnhkUeNvH41MC5+VHmLZDQiuYgRS9MAw42wEN1WAgNkbJJntwVqfjAmSMZSm55h4xPR13VbJTY= 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=IScAIbqF; 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="IScAIbqF" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=M/L9rvTnqtf8e90/h2TUjh0ieAClUaQCKeUeKBPTjeA=; b=IScAIbqFjlcHLwBQ7WwN4zM1bM eRY2QBvo+PQ4P5YYPAQIgu3pyb6swHzWI4HYEJi9gc9N5PHm7cUD/jPDtXONeyfjOhx2UpY8wYjHb XhB+JTB7d4z0YX76l+glNnjyEGAj2yOt7dH5g4wbj1kD+jVvLFd4X9ENRHsPN9pZLIqsxJKcVOLkF CO6RwKhkaQE/6rHWZSBzFYt90KFnUavYcRvl8ZBO7zMTY0i8Ml9fKdPOYla01ZBgJuZ9nHfCYPQc7 8kG+yb81Qfvxb0Ib5H1X1GIOU8+bMcYcUN+gjQhCpogZKIeRV3rN441Lr8vAOw+bu5yBNQy4BnTfK ELWEckvw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFa-00000005E7S-0JWG; Fri, 18 Oct 2024 23:19:18 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 14/17] ufs: Convert ufs_extend_tail() to take a folio Date: Sat, 19 Oct 2024 00:19:13 +0100 Message-ID: <20241018231916.1245836-14-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro From: "Matthew Wilcox (Oracle)" Pass bh->b_folio instead of bh->b_page. They're in a union, so no code change expected. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Al Viro --- fs/ufs/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 912950ee5104..1d3eb485df41 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -220,7 +220,7 @@ static u64 ufs_frag_map(struct inode *inode, unsigned offsets[4], int depth) */ static bool ufs_extend_tail(struct inode *inode, u64 writes_to, - int *err, struct page *locked_page) + int *err, struct folio *locked_folio) { struct ufs_inode_info *ufsi = UFS_I(inode); struct super_block *sb = inode->i_sb; @@ -239,7 +239,7 @@ ufs_extend_tail(struct inode *inode, u64 writes_to, p = ufs_get_direct_data_ptr(uspi, ufsi, block); tmp = ufs_new_fragments(inode, p, lastfrag, ufs_data_ptr_to_cpu(sb, p), new_size - (lastfrag & uspi->s_fpbmask), err, - locked_page); + &locked_folio->page); return tmp != 0; } @@ -413,7 +413,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff unsigned tailfrags = lastfrag & uspi->s_fpbmask; if (tailfrags && fragment >= lastfrag) { if (!ufs_extend_tail(inode, fragment, - &err, bh_result->b_page)) + &err, bh_result->b_folio)) goto out; } } From patchwork Fri Oct 18 23:19:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842491 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 BD774191496 for ; Fri, 18 Oct 2024 23:19:19 +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=1729293563; cv=none; b=qidxBsAGwvW/4D6thglIVZlqY0NalJZbjLrGqvn1r+ntoNH9l+sTwbXwbbiRGLvepSFlnJwrjZFbmOjVDgHjLvNpGkSD86WutNN3DGicQOclYuvPpmafBTBgtJWaG/808xw9v4XxoeEb6zLaC5EinUO9uPar6TPq5HhuBRDBoUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293563; c=relaxed/simple; bh=CbS0wCgwGa/cgl4sqoPf8fGMQv6ocG33GJfImcishk0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cllnCeeCHA+ixWjhhpMpklurNSsrLEE4WVH72i0t/2bUv74QkCYuMC/n+nzj5xavceasqSdQnDAkPJyDrNCD6AhVQYVH3WUOMt8oJmiICrOD3DT7wOvpJDO7FEB0+oUilZksz89Hf3qdGDz2W2fCUlr68Ks/O+fq//sF/XHMXgQ= 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=q9dDoMWU; 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="q9dDoMWU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=Ny6Os/r2A0hUmcgdRZwzqQEdajuhiY0oq+Bl9gdLMo0=; b=q9dDoMWUYmAeEQQa7EuVlS5mZp 3GiXyNBqg40ub7Y/I5CdYdD37XaERvcro12+aMxAuT4tZqs0RhA0w21C/7KK2Ltb0j9kyCVacNKhi XX0KgifgavRhdWUb2xWcvHNJbVscEnKqrWYewqdaG+8bbCSif1az7TlVpRBW1AuBfaZFtNIqA/0w/ fcdxZfk3/1qVyTXvoJUGJzQSyYMstviZfUfmUJwfozUsHzb0ug+kjimW+G1pOAOXzxFO940bk0ipA UfOCfjYEq8rjIfiYXMZXHzV/wb9AZ4PLd4QrE0Nnd2A/QtLwE9WLyOPMNZYu192nH5WZa0aweOR4Y Qn6BIY4w==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFa-00000005E7Y-0n7i; Fri, 18 Oct 2024 23:19:18 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 15/17] ufs: Convert ufs_inode_getfrag() to take a folio Date: Sat, 19 Oct 2024 00:19:14 +0100 Message-ID: <20241018231916.1245836-15-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro From: "Matthew Wilcox (Oracle)" Pass bh->b_folio instead of bh->b_page. They're in a union, so no code change expected. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Al Viro --- fs/ufs/inode.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 1d3eb485df41..30e5d695d74d 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -252,10 +252,9 @@ ufs_extend_tail(struct inode *inode, u64 writes_to, * @new: we set it if we allocate new block * @locked_page: for ufs_new_fragments() */ -static u64 -ufs_inode_getfrag(struct inode *inode, unsigned index, +static u64 ufs_inode_getfrag(struct inode *inode, unsigned index, sector_t new_fragment, int *err, - int *new, struct page *locked_page) + int *new, struct folio *locked_folio) { struct ufs_inode_info *ufsi = UFS_I(inode); struct super_block *sb = inode->i_sb; @@ -283,7 +282,7 @@ ufs_inode_getfrag(struct inode *inode, unsigned index, goal += uspi->s_fpb; } tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), - goal, nfrags, err, locked_page); + goal, nfrags, err, &locked_folio->page); if (!tmp) { *err = -ENOSPC; @@ -420,7 +419,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff if (depth == 1) { phys64 = ufs_inode_getfrag(inode, offsets[0], fragment, - &err, &new, bh_result->b_page); + &err, &new, bh_result->b_folio); } else { int i; phys64 = ufs_inode_getfrag(inode, offsets[0], fragment, From patchwork Fri Oct 18 23:19:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842489 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 BC13E191494 for ; Fri, 18 Oct 2024 23:19:19 +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=1729293562; cv=none; b=AL2WaqO3yH3vD2lmM3zADFuOu/qVXnC/A7yrC1zpPuFN8xu0h/iaKKVfX3Jy0aMX1U2iRH8QfiWPQl7U3c+cyqFMaCtBQ9jzAT/iHjECGOsTWsyBmy/FSdLtTE4ZGZaI0jrIF4oXSK44MtEGJS3kGMHifTRI3g11gEQK4AvFfcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293562; c=relaxed/simple; bh=4K38SK4ZTwMEOe1pIvQaWQ3ucuNw67nY/lkCh2lNEgg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cx/wDNVyQXzPVU1fJvCDE0nzj/5pwKLkJHn8b7j6YmBs3IY5r+jwIxqkI1xzIExCz70K0bAEm5ZmlRF5NOALgYDEbsqc1pXIqghaVVktznP7mSyChS7Wgko0UlTjkc1hmYVIdTmyXGaiJ04EgTf/LFQBXY6o7CdOTPmWz/ELdmc= 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=Y3EzEdx1; 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="Y3EzEdx1" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=MKcWVyYUe1a7W2udOjDki7kYR/9MnYTP9B1nGCuO4Z8=; b=Y3EzEdx1qaMoNMj0pOuavEnruQ cH29/f0S9Ju/aGGW8+m64bA1BVoFQ4BpVLSVkl2r9d9Q87MljxIDTT0ury+bLC1VlbGLgNJwGQxmf 3V3whoXtWVhPaAFZniHRKjdKs5Rw/C+TBd4a4t41zOLW6oH9LHiFb/S8Lmv7Xqfh/z9WRulOZ6U4i Ifa7p0wlg7/a7btx90oid2KuvYI6XvO6UwPecfMf+jHGgT7ckCY++8FYtfJpgMW51+2hVFaGI+9tm LCbOaFBD1i8cwEdWtXza2rHpa4Ik1uduFaRwOBwFCYphsLGAAvtj8G/pALZXZdMZvNdsBI/zUzeUr Q3eoNqbA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFa-00000005E7e-11sa; Fri, 18 Oct 2024 23:19:18 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 16/17] ufs: Pass a folio to ufs_new_fragments() Date: Sat, 19 Oct 2024 00:19:15 +0100 Message-ID: <20241018231916.1245836-16-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro From: "Matthew Wilcox (Oracle)" All callers now have a folio, pass it to ufs_new_fragments() instead of converting back to a page. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Al Viro --- fs/ufs/balloc.c | 10 +++++----- fs/ufs/inode.c | 8 ++++---- fs/ufs/ufs.h | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index c60006c5806c..e578e429c5d8 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -332,7 +332,7 @@ static void ufs_clear_frags(struct inode *inode, sector_t beg, unsigned int n, u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, u64 goal, unsigned count, int *err, - struct page *locked_page) + struct folio *locked_folio) { struct super_block * sb; struct ufs_sb_private_info * uspi; @@ -412,7 +412,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, result = ufs_alloc_fragments (inode, cgno, goal, count, err); if (result) { ufs_clear_frags(inode, result + oldcount, - newcount - oldcount, locked_page != NULL); + newcount - oldcount, locked_folio != NULL); *err = 0; write_seqlock(&UFS_I(inode)->meta_lock); ufs_cpu_to_data_ptr(sb, p, result); @@ -436,7 +436,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, fragment + count); read_sequnlock_excl(&UFS_I(inode)->meta_lock); ufs_clear_frags(inode, result + oldcount, newcount - oldcount, - locked_page != NULL); + locked_folio != NULL); mutex_unlock(&UFS_SB(sb)->s_lock); UFSD("EXIT, result %llu\n", (unsigned long long)result); return result; @@ -457,11 +457,11 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, result = ufs_alloc_fragments (inode, cgno, goal, request, err); if (result) { ufs_clear_frags(inode, result + oldcount, newcount - oldcount, - locked_page != NULL); + locked_folio != NULL); mutex_unlock(&UFS_SB(sb)->s_lock); ufs_change_blocknr(inode, fragment - oldcount, oldcount, uspi->s_sbbase + tmp, - uspi->s_sbbase + result, locked_page); + uspi->s_sbbase + result, &locked_folio->page); *err = 0; write_seqlock(&UFS_I(inode)->meta_lock); ufs_cpu_to_data_ptr(sb, p, result); diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 30e5d695d74d..7dc38fdef2ea 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -239,7 +239,7 @@ ufs_extend_tail(struct inode *inode, u64 writes_to, p = ufs_get_direct_data_ptr(uspi, ufsi, block); tmp = ufs_new_fragments(inode, p, lastfrag, ufs_data_ptr_to_cpu(sb, p), new_size - (lastfrag & uspi->s_fpbmask), err, - &locked_folio->page); + locked_folio); return tmp != 0; } @@ -250,7 +250,7 @@ ufs_extend_tail(struct inode *inode, u64 writes_to, * @new_fragment: number of new allocated fragment(s) * @err: we set it if something wrong * @new: we set it if we allocate new block - * @locked_page: for ufs_new_fragments() + * @locked_folio: for ufs_new_fragments() */ static u64 ufs_inode_getfrag(struct inode *inode, unsigned index, sector_t new_fragment, int *err, @@ -282,7 +282,7 @@ static u64 ufs_inode_getfrag(struct inode *inode, unsigned index, goal += uspi->s_fpb; } tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), - goal, nfrags, err, &locked_folio->page); + goal, nfrags, err, locked_folio); if (!tmp) { *err = -ENOSPC; @@ -347,7 +347,7 @@ static u64 ufs_inode_getblock(struct inode *inode, u64 ind_block, else goal = bh->b_blocknr + uspi->s_fpb; tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), goal, - uspi->s_fpb, err, &locked_folio->page); + uspi->s_fpb, err, locked_folio); if (!tmp) goto out; diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index c7638e62ffe8..e7df65dd4351 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h @@ -88,10 +88,10 @@ struct ufs_inode_info { #endif /* balloc.c */ -extern void ufs_free_fragments (struct inode *, u64, unsigned); -extern void ufs_free_blocks (struct inode *, u64, unsigned); -extern u64 ufs_new_fragments(struct inode *, void *, u64, u64, - unsigned, int *, struct page *); +void ufs_free_fragments (struct inode *, u64 fragment, unsigned count); +void ufs_free_blocks (struct inode *, u64 fragment, unsigned count); +u64 ufs_new_fragments(struct inode *, void *, u64 fragment, u64 goal, + unsigned count, int *err, struct folio *); /* cylinder.c */ extern struct ufs_cg_private_info * ufs_load_cylinder (struct super_block *, unsigned); From patchwork Fri Oct 18 23:19:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13842487 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 229C9191499 for ; Fri, 18 Oct 2024 23:19:19 +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=1729293561; cv=none; b=XGBk0CqffTb6YUtPTpseUq8V1JVrV/09KaZ7Efl+F6FR56u8PDQad8DZE66elXPzo67IjCs7Fw1k7FBr7epAV6FpMCJMuZoNBq6haWM+95ygnaKpGK5pYBqxEcxr1IuBnhohxJuhn80Lo63nSXkR1V/JBeuRqyynWzvW9Kdi8qU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729293561; c=relaxed/simple; bh=mSNS9ZHb8J9edBLOFDSeE7333fa+R46m4eR55ErzdE4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n3pfAPuUJ78NLlgjwiUGuoWxI5DIe1sNyUpQq5joIzI4BKSqW7vPs5H70zXzhuJQ522I+JxMQK9lJcoQmtrFrQlRMOanXgEA02i6t7cnZe07dh8cGQnZaYxZ3SJuGuFBVpe9RH0OjHqz2qTJO5IpUWBJ+cHMvH36aROFtlH5m/s= 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=cUQyrC8/; 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="cUQyrC8/" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=hkA09h+I6ixav+0+EPxzrhhq+sYWxN3umjrMUgBsxJ4=; b=cUQyrC8/T03/HmqQyJKPiUyeJ7 fKmOy3vZg/PT3p1ElX87D4ixCO00YH6Vx7D0TDSj0L5DZdt+t9uN4RMnB/xSB2POcgNztgdxHk6ab rCESJp4ob/fRsE8o21pMahuHhcIi1IVAKBX7D54SDZinrqt0eHEHUc5DrUQK1lGSyfo9Gfq2IFPn4 +V+ndlDG2HvydDwWywgwDQCLtyLaRkXnVXPyKJYxlmgUTU7hlWuDrwztl4C+B6zRN5Myr6j/X9S84 s1wIJhZLi0Lt2+O7BR88aMM/Us2XDyyGlPewI7f/pD1vVgM7ySEbVfpr9TGb2jH8g6v0oxjhisHqY G5IaC/lw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1wFa-00000005E7k-1Ls3; Fri, 18 Oct 2024 23:19:18 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Evgeniy Dushistov , Matthew Wilcox , Christian Brauner , Jan Kara Subject: [PATCH 17/17] ufs: Convert ufs_change_blocknr() to take a folio Date: Sat, 19 Oct 2024 00:19:16 +0100 Message-ID: <20241018231916.1245836-17-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241018231916.1245836-1-viro@zeniv.linux.org.uk> References: <20241018231428.GC1172273@ZenIV> <20241018231916.1245836-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro From: "Matthew Wilcox (Oracle)" Now that ufs_new_fragments() has a folio, pass it to ufs_change_blocknr() as a folio instead of converting it from folio to page to folio. This removes the last use of struct page in UFS. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Al Viro --- fs/ufs/balloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index e578e429c5d8..194ed3ab945e 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -229,13 +229,13 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count) * situated at the end of file. * * We can come here from ufs_writepage or ufs_prepare_write, - * locked_page is argument of these functions, so we already lock it. + * locked_folio is argument of these functions, so we already lock it. */ static void ufs_change_blocknr(struct inode *inode, sector_t beg, unsigned int count, sector_t oldb, - sector_t newb, struct page *locked_page) + sector_t newb, struct folio *locked_folio) { - struct folio *folio, *locked_folio = page_folio(locked_page); + struct folio *folio; const unsigned blks_per_page = 1 << (PAGE_SHIFT - inode->i_blkbits); const unsigned mask = blks_per_page - 1; @@ -461,7 +461,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment, mutex_unlock(&UFS_SB(sb)->s_lock); ufs_change_blocknr(inode, fragment - oldcount, oldcount, uspi->s_sbbase + tmp, - uspi->s_sbbase + result, &locked_folio->page); + uspi->s_sbbase + result, locked_folio); *err = 0; write_seqlock(&UFS_I(inode)->meta_lock); ufs_cpu_to_data_ptr(sb, p, result);