From patchwork Tue Jul 9 15:03:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13728214 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 243F419D09E for ; Tue, 9 Jul 2024 15:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537401; cv=none; b=eZPGqW8rW50N3e0+HYKoIqcASfyx866+T4jjCffubUsInqz2feB2NiyAwlhpSnRnaHi5fTpTR4yQk94Cj138XNxCJfHPrtqtsciwNxxViBEdFEXDe9DKOZ1q39Jm6bYKG+xR1BUpzrTBWB+QG9AuKOYBIqUks5nIgBmPe+OWU+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537401; c=relaxed/simple; bh=hqIGeaGEyzuGpKBLu6VwBTRqREi9APVz9HnlUlzCW20=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mh0GiRYES+bV0QDdvXHHUBP9BqzNOR6AKUUA//1XlgnP15QqWndB6Uor/g5bnuN4pgmcaYiS4Ma7VLJzoEGs3wyyij7ZQOVmHVXuwS106dMfcECH4EhjRVLKvw1rp9zS4gYR3rQAB2bSjzvFYfasYI23iwXyiI/NzgqWvf02a3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=GHvPjwFH; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="GHvPjwFH" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=feDi5aSsC+9xS4VEriWMgV/zl7jn3RYQP9Y+adzQmFc=; b=GHvPjwFHF+8v8UH2/fR/qc4u/V qfkzXK06JORQeErcL+yQBeLxDcV631DZTPHMSgwamSWI4qtLyt1vyB8SInguah+td1QiAdoJzuKXr BNaUh7GgGsBXgIlAbFeNiNDHuM+MQv6mKsMZItmaLffyKYUK4OCXIQxkWst2QZFDCsoxCimfoLHv4 mw0CQD5nbFb5mj+dcVdr89HSSX5gm+DQ0SRLoRthgC2S30DXYrC2//8K1PNl89O+sM5SO28OuP5ON 7IaLugwRfHsEztmQRWxJzWo27W9cmHPyHVhUg5LKXaNPYtCBvqBA6/HVxjUlqsBI58EdzXVQkxhDj YCJ/uLig==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRCN9-00000007zrs-2N06; Tue, 09 Jul 2024 15:03:15 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 1/7] sysv: Convert dir_get_page() to dir_get_folio() Date: Tue, 9 Jul 2024 16:03:06 +0100 Message-ID: <20240709150314.1906109-2-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709150314.1906109-1-willy@infradead.org> References: <20240709150314.1906109-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove a few conversions between page and folio. Signed-off-by: Matthew Wilcox (Oracle) --- fs/sysv/dir.c | 80 +++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 2e126d72d619..1f95f82f8941 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -52,20 +52,21 @@ static int sysv_handle_dirsync(struct inode *dir) } /* - * Calls to dir_get_page()/unmap_and_put_page() must be nested according to the + * Calls to dir_get_folio()/folio_release_kmap() must be nested according to the * rules documented in mm/highmem.rst. * - * NOTE: sysv_find_entry() and sysv_dotdot() act as calls to dir_get_page() + * NOTE: sysv_find_entry() and sysv_dotdot() act as calls to dir_get_folio() * and must be treated accordingly for nesting purposes. */ -static void *dir_get_page(struct inode *dir, unsigned long n, struct page **p) +static void *dir_get_folio(struct inode *dir, unsigned long n, + struct folio **foliop) { - struct address_space *mapping = dir->i_mapping; - struct page *page = read_mapping_page(mapping, n, NULL); - if (IS_ERR(page)) - return ERR_CAST(page); - *p = page; - return kmap_local_page(page); + struct folio *folio = read_mapping_folio(dir->i_mapping, n, NULL); + + if (IS_ERR(folio)) + return ERR_CAST(folio); + *foliop = folio; + return kmap_local_folio(folio, 0); } static int sysv_readdir(struct file *file, struct dir_context *ctx) @@ -87,9 +88,9 @@ static int sysv_readdir(struct file *file, struct dir_context *ctx) for ( ; n < npages; n++, offset = 0) { char *kaddr, *limit; struct sysv_dir_entry *de; - struct page *page; + struct folio *folio; - kaddr = dir_get_page(inode, n, &page); + kaddr = dir_get_folio(inode, n, &folio); if (IS_ERR(kaddr)) continue; de = (struct sysv_dir_entry *)(kaddr+offset); @@ -103,11 +104,11 @@ static int sysv_readdir(struct file *file, struct dir_context *ctx) if (!dir_emit(ctx, name, strnlen(name,SYSV_NAMELEN), fs16_to_cpu(SYSV_SB(sb), de->inode), DT_UNKNOWN)) { - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return 0; } } - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); } return 0; } @@ -133,7 +134,7 @@ static inline int namecompare(int len, int maxlen, * * On Success unmap_and_put_page() should be called on *res_page. * - * sysv_find_entry() acts as a call to dir_get_page() and must be treated + * sysv_find_entry() acts as a call to dir_get_folio() and must be treated * accordingly for nesting purposes. */ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_page) @@ -143,7 +144,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_ struct inode * dir = d_inode(dentry->d_parent); unsigned long start, n; unsigned long npages = dir_pages(dir); - struct page *page = NULL; + struct folio *folio = NULL; struct sysv_dir_entry *de; *res_page = NULL; @@ -154,7 +155,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_ n = start; do { - char *kaddr = dir_get_page(dir, n, &page); + char *kaddr = dir_get_folio(dir, n, &folio); if (!IS_ERR(kaddr)) { de = (struct sysv_dir_entry *)kaddr; @@ -166,7 +167,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_ name, de->name)) goto found; } - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); } if (++n >= npages) @@ -177,7 +178,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_ found: SYSV_I(dir)->i_dir_start_lookup = n; - *res_page = page; + *res_page = &folio->page; return de; } @@ -186,7 +187,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) struct inode *dir = d_inode(dentry->d_parent); const char * name = dentry->d_name.name; int namelen = dentry->d_name.len; - struct page *page = NULL; + struct folio *folio = NULL; struct sysv_dir_entry * de; unsigned long npages = dir_pages(dir); unsigned long n; @@ -196,7 +197,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) /* We take care of directory expansion in the same loop */ for (n = 0; n <= npages; n++) { - kaddr = dir_get_page(dir, n, &page); + kaddr = dir_get_folio(dir, n, &folio); if (IS_ERR(kaddr)) return PTR_ERR(kaddr); de = (struct sysv_dir_entry *)kaddr; @@ -206,33 +207,33 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) goto got_it; err = -EEXIST; if (namecompare(namelen, SYSV_NAMELEN, name, de->name)) - goto out_page; + goto out_folio; de++; } - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); } BUG(); return -EINVAL; got_it: - pos = page_offset(page) + offset_in_page(de); - lock_page(page); - err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); + pos = folio_pos(folio) + offset_in_folio(folio, de); + folio_lock(folio); + err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE); if (err) goto out_unlock; memcpy (de->name, name, namelen); memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2); de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); - dir_commit_chunk(page, pos, SYSV_DIRSIZE); + dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); mark_inode_dirty(dir); err = sysv_handle_dirsync(dir); -out_page: - unmap_and_put_page(page, kaddr); +out_folio: + folio_release_kmap(folio, kaddr); return err; out_unlock: - unlock_page(page); - goto out_page; + folio_unlock(folio); + goto out_folio; } int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page) @@ -292,19 +293,19 @@ int sysv_make_empty(struct inode *inode, struct inode *dir) int sysv_empty_dir(struct inode * inode) { struct super_block *sb = inode->i_sb; - struct page *page = NULL; + struct folio *folio = NULL; unsigned long i, npages = dir_pages(inode); char *kaddr; for (i = 0; i < npages; i++) { struct sysv_dir_entry *de; - kaddr = dir_get_page(inode, i, &page); + kaddr = dir_get_folio(inode, i, &folio); if (IS_ERR(kaddr)) continue; de = (struct sysv_dir_entry *)kaddr; - kaddr += PAGE_SIZE-SYSV_DIRSIZE; + kaddr += folio_size(folio) - SYSV_DIRSIZE; for ( ;(char *)de <= kaddr; de++) { if (!de->inode) @@ -321,12 +322,12 @@ int sysv_empty_dir(struct inode * inode) if (de->name[1] != '.' || de->name[2]) goto not_empty; } - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); } return 1; not_empty: - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return 0; } @@ -352,18 +353,21 @@ int sysv_set_link(struct sysv_dir_entry *de, struct page *page, } /* - * Calls to dir_get_page()/unmap_and_put_page() must be nested according to the + * Calls to dir_get_folio()/folio_release_kmap() must be nested according to the * rules documented in mm/highmem.rst. * - * sysv_dotdot() acts as a call to dir_get_page() and must be treated + * sysv_dotdot() acts as a call to dir_get_folio() and must be treated * accordingly for nesting purposes. */ struct sysv_dir_entry *sysv_dotdot(struct inode *dir, struct page **p) { - struct sysv_dir_entry *de = dir_get_page(dir, 0, p); + struct folio *folio; + + struct sysv_dir_entry *de = dir_get_folio(dir, 0, &folio); if (IS_ERR(de)) return NULL; + *p = &folio->page; /* ".." is the second directory entry */ return de + 1; } From patchwork Tue Jul 9 15:03:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13728212 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 3DD8B1836DC for ; Tue, 9 Jul 2024 15:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537399; cv=none; b=Bhix1eHqYMsdYm/Z2g7ATiRs6YxqpCTtUhDCJP2V76Y/h9Nicp7jCr65IM2/+zzRRq2VAzEvjoiG+NV5K42PO09B51Vodb/gfB9+PX+GPd0WYVtNooyN5NCn+usRS/5tjBe5VVZPX0HphtGAQN0RdmdGGDf0ziPqHg+VgpjWD3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537399; c=relaxed/simple; bh=e4L1wh7mbuGZ0ej7AAcNTWMdvFVzi18WV65B6RximHI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LNWmYFvM03Pj5ECPWbHRVwdv0SmTbEinF1k88YiQvdmF6sa6qTaL0u8GgzUKYC2IRdzk/lIG4aWN+LQg8yVUTEyigyQhbQ8/SMXW9pYq+/d95jRMF6GcFUNZ6ho2wuSJiGdh/UA7UNS6/vDOVf6PoN3EQXm7wZT0L+vdr0Q9ue0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=txqTak/0; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="txqTak/0" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=qWokI/l0Zrn7s5mSXtC70jpneuZ21jD1PZrI1NlOQxA=; b=txqTak/0j5SAkI8H6SX2B4B6j9 jeSpJHtERYLZo0QwAoC1Lg1Ko6E/yJk4INkZSqpKicqvGm5q+7+hxhTJK9I1/HClIcNMdEo44GNQF tVglbwolzltt7Yh0zbiZLxJJrvl6jYIkII2kgRpSP42gtm1NHJel7u3y3kUQers2DwD93rSdkuJ8N 1tisvzmidl3u/EVklvE43WjBaJNNT7Vq4KxXYvn3nukp+KNRONZ77d0t4H3OKfF88/RyM3okEkubl 0qZpnx0U4n+t+M50ij4P68gnxTzPiz9DRE2xIOzsxGAxIeMCsSjJe5tbMK0CLaWioyTgfsnfmVNPZ 4c/jUU2w==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRCN9-00000007zru-2mKx; Tue, 09 Jul 2024 15:03:15 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 2/7] sysv: Convert sysv_find_entry() to take a folio Date: Tue, 9 Jul 2024 16:03:07 +0100 Message-ID: <20240709150314.1906109-3-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709150314.1906109-1-willy@infradead.org> References: <20240709150314.1906109-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/sysv/dir.c | 25 ++++++++++--------------- fs/sysv/namei.c | 24 ++++++++++++------------ fs/sysv/sysv.h | 16 ++++++++-------- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 1f95f82f8941..5b2e3c7c2971 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -127,39 +127,35 @@ static inline int namecompare(int len, int maxlen, /* * sysv_find_entry() * - * finds an entry in the specified directory with the wanted name. It - * returns the cache buffer in which the entry was found, and the entry - * itself (as a parameter - res_dir). It does NOT read the inode of the + * finds an entry in the specified directory with the wanted name. + * It does NOT read the inode of the * entry - you'll have to do that yourself if you want to. * - * On Success unmap_and_put_page() should be called on *res_page. + * On Success folio_release_kmap() should be called on *foliop. * * sysv_find_entry() acts as a call to dir_get_folio() and must be treated * accordingly for nesting purposes. */ -struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_page) +struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct folio **foliop) { const char * name = dentry->d_name.name; int namelen = dentry->d_name.len; struct inode * dir = d_inode(dentry->d_parent); unsigned long start, n; unsigned long npages = dir_pages(dir); - struct folio *folio = NULL; struct sysv_dir_entry *de; - *res_page = NULL; - start = SYSV_I(dir)->i_dir_start_lookup; if (start >= npages) start = 0; n = start; do { - char *kaddr = dir_get_folio(dir, n, &folio); + char *kaddr = dir_get_folio(dir, n, foliop); if (!IS_ERR(kaddr)) { de = (struct sysv_dir_entry *)kaddr; - kaddr += PAGE_SIZE - SYSV_DIRSIZE; + kaddr += folio_size(*foliop) - SYSV_DIRSIZE; for ( ; (char *) de <= kaddr ; de++) { if (!de->inode) continue; @@ -167,7 +163,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_ name, de->name)) goto found; } - folio_release_kmap(folio, kaddr); + folio_release_kmap(*foliop, kaddr); } if (++n >= npages) @@ -178,7 +174,6 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_ found: SYSV_I(dir)->i_dir_start_lookup = n; - *res_page = &folio->page; return de; } @@ -374,13 +369,13 @@ struct sysv_dir_entry *sysv_dotdot(struct inode *dir, struct page **p) ino_t sysv_inode_by_name(struct dentry *dentry) { - struct page *page; - struct sysv_dir_entry *de = sysv_find_entry (dentry, &page); + struct folio *folio; + struct sysv_dir_entry *de = sysv_find_entry (dentry, &folio); ino_t res = 0; if (de) { res = fs16_to_cpu(SYSV_SB(dentry->d_sb), de->inode); - unmap_and_put_page(page, de); + folio_release_kmap(folio, de); } return res; } diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index d6b73798071b..970043fe49ee 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c @@ -151,20 +151,20 @@ static int sysv_mkdir(struct mnt_idmap *idmap, struct inode *dir, static int sysv_unlink(struct inode * dir, struct dentry * dentry) { struct inode * inode = d_inode(dentry); - struct page * page; + struct folio *folio; struct sysv_dir_entry * de; int err; - de = sysv_find_entry(dentry, &page); + de = sysv_find_entry(dentry, &folio); if (!de) return -ENOENT; - err = sysv_delete_entry(de, page); + err = sysv_delete_entry(de, &folio->page); if (!err) { inode_set_ctime_to_ts(inode, inode_get_ctime(dir)); inode_dec_link_count(inode); } - unmap_and_put_page(page, de); + folio_release_kmap(folio, de); return err; } @@ -196,14 +196,14 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, struct inode * new_inode = d_inode(new_dentry); struct page * dir_page = NULL; struct sysv_dir_entry * dir_de = NULL; - struct page * old_page; + struct folio *old_folio; struct sysv_dir_entry * old_de; int err = -ENOENT; if (flags & ~RENAME_NOREPLACE) return -EINVAL; - old_de = sysv_find_entry(old_dentry, &old_page); + old_de = sysv_find_entry(old_dentry, &old_folio); if (!old_de) goto out; @@ -215,7 +215,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, } if (new_inode) { - struct page * new_page; + struct folio *new_folio; struct sysv_dir_entry * new_de; err = -ENOTEMPTY; @@ -223,11 +223,11 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, goto out_dir; err = -ENOENT; - new_de = sysv_find_entry(new_dentry, &new_page); + new_de = sysv_find_entry(new_dentry, &new_folio); if (!new_de) goto out_dir; - err = sysv_set_link(new_de, new_page, old_inode); - unmap_and_put_page(new_page, new_de); + err = sysv_set_link(new_de, &new_folio->page, old_inode); + folio_release_kmap(new_folio, new_de); if (err) goto out_dir; inode_set_ctime_current(new_inode); @@ -242,7 +242,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, inode_inc_link_count(new_dir); } - err = sysv_delete_entry(old_de, old_page); + err = sysv_delete_entry(old_de, &old_folio->page); if (err) goto out_dir; @@ -258,7 +258,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, if (dir_de) unmap_and_put_page(dir_page, dir_de); out_old: - unmap_and_put_page(old_page, old_de); + folio_release_kmap(old_folio, old_de); out: return err; } diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h index e3f988b469ee..be15c659a027 100644 --- a/fs/sysv/sysv.h +++ b/fs/sysv/sysv.h @@ -148,15 +148,15 @@ extern void sysv_destroy_icache(void); /* dir.c */ -extern struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct page **); -extern int sysv_add_link(struct dentry *, struct inode *); -extern int sysv_delete_entry(struct sysv_dir_entry *, struct page *); -extern int sysv_make_empty(struct inode *, struct inode *); -extern int sysv_empty_dir(struct inode *); -extern int sysv_set_link(struct sysv_dir_entry *, struct page *, +struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct folio **); +int sysv_add_link(struct dentry *, struct inode *); +int sysv_delete_entry(struct sysv_dir_entry *, struct page *); +int sysv_make_empty(struct inode *, struct inode *); +int sysv_empty_dir(struct inode *); +int sysv_set_link(struct sysv_dir_entry *, struct page *, struct inode *); -extern struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **); -extern ino_t sysv_inode_by_name(struct dentry *); +struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **); +ino_t sysv_inode_by_name(struct dentry *); extern const struct inode_operations sysv_file_inode_operations; From patchwork Tue Jul 9 15:03:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13728213 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 9982119CCE8 for ; Tue, 9 Jul 2024 15:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537400; cv=none; b=QagLVDwGVK13FeQZxi13D9sBREk44MHanJrKaZ49cz6eyp4wprPkHV4gsehsT4Q6QsbH+k2k3/gYwLUi1teK9TgRCEESOHe2UY9csnPRYGqqnU9XmqV6s2CnVeLeMwMxLK1ZKoUjzm8dlDglVBgyn0KsrZUhYwvzBBBQNanycsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537400; c=relaxed/simple; bh=jssJsGARWMzSFAhp9zZZJUdYG2vwfUG0aQIxNKhL3nc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fcoDPadY25Z/CUhoUXXibqfMkInumiS4puVleR6z5wKFtH8O7GC4fJ6LTY+FCnlc1njihvF2tw77Dm9hj+wU7ZdHTzvVsrIqHJ9zE2cC0nho4DwJk8hnvGMgTzWULsASvvZSMa+IWQJ7uOx9KYCn9PVkITe3QgLBh97RpDuPOX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=cAyqJZuD; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="cAyqJZuD" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=BE9x7wCw8UMWOEVAiCw3SIS/KUZX7ZNyTILs/3gwvOk=; b=cAyqJZuDWd9MoGB2qwjY+8tnhT UG9/dYI8L3dC/u6xf2kN0XE8Jy9H2N7Grj26CDmmIiPwpflgsMbq00x241+RzCY7prxrzoVv8wWEV iyt73sHeyuQzTfhQ1gpp5tzKVfF0ZRk0w5EtuG7k6dpTRX+Y3EXoZvJ3pihaigciGfCHaUR95XnJE XokMXmXyEFBjxnpIKZf2RqkSwmZJlNNa4Sgcz/hRcSVWql5F3mn+mmG6oHYsFnQr/1hC18G4HMw2B je6sfh47zEqJJrKEIOtUN2TvIodNy3IpTPNzmRRCQ94baCUGW+5yoUWw83X70/5kMnSUIUC3fTBHD 2qRD068A==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRCN9-00000007zry-3GUB; Tue, 09 Jul 2024 15:03:15 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 3/7] sysv: Convert sysv_set_link() and sysv_dotdot() to take a folio Date: Tue, 9 Jul 2024 16:03:08 +0100 Message-ID: <20240709150314.1906109-4-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709150314.1906109-1-willy@infradead.org> References: <20240709150314.1906109-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This matches ext2 and removes a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/sysv/dir.c | 23 ++++++++++------------- fs/sysv/namei.c | 10 +++++----- fs/sysv/sysv.h | 4 ++-- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 5b2e3c7c2971..ebccf7bb5b69 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -327,21 +327,21 @@ int sysv_empty_dir(struct inode * inode) } /* Releases the page */ -int sysv_set_link(struct sysv_dir_entry *de, struct page *page, - struct inode *inode) +int sysv_set_link(struct sysv_dir_entry *de, struct folio *folio, + struct inode *inode) { - struct inode *dir = page->mapping->host; - loff_t pos = page_offset(page) + offset_in_page(de); + struct inode *dir = folio->mapping->host; + loff_t pos = folio_pos(folio) + offset_in_folio(folio, de); int err; - lock_page(page); - err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); + folio_lock(folio); + err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE); if (err) { - unlock_page(page); + folio_unlock(folio); return err; } de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); - dir_commit_chunk(page, pos, SYSV_DIRSIZE); + dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); mark_inode_dirty(dir); return sysv_handle_dirsync(inode); @@ -354,15 +354,12 @@ int sysv_set_link(struct sysv_dir_entry *de, struct page *page, * sysv_dotdot() acts as a call to dir_get_folio() and must be treated * accordingly for nesting purposes. */ -struct sysv_dir_entry *sysv_dotdot(struct inode *dir, struct page **p) +struct sysv_dir_entry *sysv_dotdot(struct inode *dir, struct folio **foliop) { - struct folio *folio; - - struct sysv_dir_entry *de = dir_get_folio(dir, 0, &folio); + struct sysv_dir_entry *de = dir_get_folio(dir, 0, foliop); if (IS_ERR(de)) return NULL; - *p = &folio->page; /* ".." is the second directory entry */ return de + 1; } diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index 970043fe49ee..ef4d91431225 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c @@ -194,7 +194,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, { struct inode * old_inode = d_inode(old_dentry); struct inode * new_inode = d_inode(new_dentry); - struct page * dir_page = NULL; + struct folio *dir_folio; struct sysv_dir_entry * dir_de = NULL; struct folio *old_folio; struct sysv_dir_entry * old_de; @@ -209,7 +209,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, if (S_ISDIR(old_inode->i_mode)) { err = -EIO; - dir_de = sysv_dotdot(old_inode, &dir_page); + dir_de = sysv_dotdot(old_inode, &dir_folio); if (!dir_de) goto out_old; } @@ -226,7 +226,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, new_de = sysv_find_entry(new_dentry, &new_folio); if (!new_de) goto out_dir; - err = sysv_set_link(new_de, &new_folio->page, old_inode); + err = sysv_set_link(new_de, new_folio, old_inode); folio_release_kmap(new_folio, new_de); if (err) goto out_dir; @@ -249,14 +249,14 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, mark_inode_dirty(old_inode); if (dir_de) { - err = sysv_set_link(dir_de, dir_page, new_dir); + err = sysv_set_link(dir_de, dir_folio, new_dir); if (!err) inode_dec_link_count(old_dir); } out_dir: if (dir_de) - unmap_and_put_page(dir_page, dir_de); + folio_release_kmap(dir_folio, dir_de); out_old: folio_release_kmap(old_folio, old_de); out: diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h index be15c659a027..ee90af7dbed9 100644 --- a/fs/sysv/sysv.h +++ b/fs/sysv/sysv.h @@ -153,9 +153,9 @@ int sysv_add_link(struct dentry *, struct inode *); int sysv_delete_entry(struct sysv_dir_entry *, struct page *); int sysv_make_empty(struct inode *, struct inode *); int sysv_empty_dir(struct inode *); -int sysv_set_link(struct sysv_dir_entry *, struct page *, +int sysv_set_link(struct sysv_dir_entry *, struct folio *, struct inode *); -struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **); +struct sysv_dir_entry *sysv_dotdot(struct inode *, struct folio **); ino_t sysv_inode_by_name(struct dentry *); From patchwork Tue Jul 9 15:03:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13728208 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 7D4F919B5A7 for ; Tue, 9 Jul 2024 15:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537399; cv=none; b=KYvNiUIMkX8HnYiktK42+j1mIS9PF9JFZNMBmblyNR4nrz/SmTbSSPOOz4r2MxU2AsGbsEdM8evJVuJ8cc09NW+fN2MLMPRhAEynApH3bi5EwrkeE1WNUHolGTybAArtU71hE+KBJVPz1oiFR+mgeKu+xguhnW6/UmnOdnF2q0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537399; c=relaxed/simple; bh=pR/evf6fgpCcR4KJcPc68T0ddSvcCZOTsd0g8PTsJEg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P5jgYCYWQvW+I8aVclbH8XMROiZ+NiMlSd+XRrZlUg6hXcsehE2hVgTK71jiYyBvq9HCxaod5EJucQjwH1LizqKw8pbbXvOnvlO7nZAYeXcKilgTgclOR42pkCRPygpIkXvrnL0wxcKuIgQID/lP/RtDfujTHoFYtsPT+wt7TUA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=vyZWr6Sf; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="vyZWr6Sf" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=N/jZsrB0iio5olmL2oPkcxaiTdmgwtyxJM489B0zWkc=; b=vyZWr6SftOn5H5j4YAOMbUe3Rx r7urs2REIC5GMYdojM+lGx+us8ekcv34aiv0clDORqNMg/YNIk6aMChLXKk+iLox9rJO8BGtjY9qH cNTRFR3FeYHCi+UfFPRQG1D1WZDvuTfdcc3ufygst2VtCQLHTIVT10tpoazZYlsaRbiaGfWa3fzNO 8yAY7doZL3T02S6C3aZPS2tHNlXfV7rIZYPyStz4K5ULRNWuPiABBnN3da4BePhhLHkCphb4y2NlL mkOl1/cURLwVRiArhzrZDJWAPWHgoNDFrVo6UeIRh42B0Z3gPC/LpA20Nb4g3Y4SHFvNUdMMq5V+f dF+5qyCg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRCN9-00000007zs9-3ql8; Tue, 09 Jul 2024 15:03:15 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 4/7] sysv: Convert sysv_delete_entry() to work on a folio Date: Tue, 9 Jul 2024 16:03:09 +0100 Message-ID: <20240709150314.1906109-5-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709150314.1906109-1-willy@infradead.org> References: <20240709150314.1906109-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Match ext2 and remove a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/sysv/dir.c | 14 +++++++------- fs/sysv/namei.c | 4 ++-- fs/sysv/sysv.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index ebccf7bb5b69..0b5727510bdd 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -231,20 +231,20 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) goto out_folio; } -int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page) +int sysv_delete_entry(struct sysv_dir_entry *de, struct folio *folio) { - struct inode *inode = page->mapping->host; - loff_t pos = page_offset(page) + offset_in_page(de); + struct inode *inode = folio->mapping->host; + loff_t pos = folio_pos(folio) + offset_in_folio(folio, de); int err; - lock_page(page); - err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); + folio_lock(folio); + err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE); if (err) { - unlock_page(page); + folio_unlock(folio); return err; } de->inode = 0; - dir_commit_chunk(page, pos, SYSV_DIRSIZE); + dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); mark_inode_dirty(inode); return sysv_handle_dirsync(inode); diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index ef4d91431225..fb8bd8437872 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c @@ -159,7 +159,7 @@ static int sysv_unlink(struct inode * dir, struct dentry * dentry) if (!de) return -ENOENT; - err = sysv_delete_entry(de, &folio->page); + err = sysv_delete_entry(de, folio); if (!err) { inode_set_ctime_to_ts(inode, inode_get_ctime(dir)); inode_dec_link_count(inode); @@ -242,7 +242,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, inode_inc_link_count(new_dir); } - err = sysv_delete_entry(old_de, &old_folio->page); + err = sysv_delete_entry(old_de, old_folio); if (err) goto out_dir; diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h index ee90af7dbed9..fec9f6b883d5 100644 --- a/fs/sysv/sysv.h +++ b/fs/sysv/sysv.h @@ -150,7 +150,7 @@ extern void sysv_destroy_icache(void); /* dir.c */ struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct folio **); int sysv_add_link(struct dentry *, struct inode *); -int sysv_delete_entry(struct sysv_dir_entry *, struct page *); +int sysv_delete_entry(struct sysv_dir_entry *, struct folio *); int sysv_make_empty(struct inode *, struct inode *); int sysv_empty_dir(struct inode *); int sysv_set_link(struct sysv_dir_entry *, struct folio *, From patchwork Tue Jul 9 15:03:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13728209 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 9BD5919CCEC for ; Tue, 9 Jul 2024 15:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537399; cv=none; b=OqkCWjhF7mIIzbgrhWNMINaA46dyCexs/viLFGC9wbIvPzDD7ZfggbpkMKgT0tcKWOgZhy/+0sXM1fXhcUcPVGYoOn99wBTsUtqven1uzfNtea0oYfYzWVB6sBncIm6eHbn1Bqk0u2IptEXup4CtrQbz/O6xBKKeK1I+FaXJUtc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537399; c=relaxed/simple; bh=v2tNyUkP3KSJhx/1ZB1TFE/82Ojvyt/eXWK/VKhaTfQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c/7kHyJzr0Z3Ud1RdN2vmAAasb+vBGzFpHyqGrq7zrRsNX2QJEVWIQfGb3YC8YB37sPdhz7jNHn+j531Crn1qEwynwdwgQ4sC5jNp+ueZyGLVqiIwlvCImNrRq7K+r+XR59du0rr6mvcCYax60MgpP8DP+7aAphz6KklAG6CUS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=UrnUgGSs; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="UrnUgGSs" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=iXX71Zvhf734SndPuAiOuMl7U4rwU9SGjy7BFabuU4w=; b=UrnUgGSsos/oz2+OqIUtOaIHLM QrRh/YLr8KgvZKOtLzdNiQ/886yF+aBaBqtXKChk1qeonPQVFoa7kzNhhZD9OxlDEeFMtRaOxPoLo bkBgMWfIQWgN+p5jkuGXtz76yq34gX2rsDN4ZTYzSMSi9nESyL1aAAtpT5lLmOaZrGfc2Xgj931kw g4vVUS5CtMIDaem+fh/ibiE1nu2Y4Lw4YoTQLJJBme5mpUngCEVT2t5YwrP7LzvMEDoPTjNK5xrAD qNexKqiD7aKN+Zja7EIIEISbZVK+GOnTGHcqZb5uEzRrBpNqH0ohScz81Sdjz6rjXXzh+fpHZtYYH 7yt9Nl8g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRCNA-00000007zsG-0BDF; Tue, 09 Jul 2024 15:03:16 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 5/7] sysv: Convert sysv_make_empty() to use a folio Date: Tue, 9 Jul 2024 16:03:10 +0100 Message-ID: <20240709150314.1906109-6-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709150314.1906109-1-willy@infradead.org> References: <20240709150314.1906109-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Removes a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/sysv/dir.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 0b5727510bdd..5f91a82a2966 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -252,33 +252,33 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct folio *folio) int sysv_make_empty(struct inode *inode, struct inode *dir) { - struct page *page = grab_cache_page(inode->i_mapping, 0); + struct folio *folio = filemap_grab_folio(inode->i_mapping, 0); struct sysv_dir_entry * de; - char *base; + char *kaddr; int err; - if (!page) - return -ENOMEM; - err = sysv_prepare_chunk(page, 0, 2 * SYSV_DIRSIZE); + if (IS_ERR(folio)) + return PTR_ERR(folio); + err = sysv_prepare_chunk(&folio->page, 0, 2 * SYSV_DIRSIZE); if (err) { - unlock_page(page); + folio_unlock(folio); goto fail; } - base = kmap_local_page(page); - memset(base, 0, PAGE_SIZE); + kaddr = kmap_local_folio(folio, 0); + memset(kaddr, 0, folio_size(folio)); - de = (struct sysv_dir_entry *) base; + de = (struct sysv_dir_entry *)kaddr; de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); strcpy(de->name,"."); de++; de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), dir->i_ino); strcpy(de->name,".."); - kunmap_local(base); - dir_commit_chunk(page, 0, 2 * SYSV_DIRSIZE); + kunmap_local(kaddr); + dir_commit_chunk(&folio->page, 0, 2 * SYSV_DIRSIZE); err = sysv_handle_dirsync(inode); fail: - put_page(page); + folio_put(folio); return err; } From patchwork Tue Jul 9 15:03:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13728211 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 9D4A319CCED for ; Tue, 9 Jul 2024 15:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537399; cv=none; b=tC4q+JgYdQbJFrPYqQ6Bu/RIi92tb1PnAFy93sIJ42BJJCBn7rC/5ZMXeFOvncCKa7XQaOis4brqULfmQaFyMW80HfvpLC72tlr93eV3J5ye9HIc8uB3w4Cozxg15GEVLOEbSM7EUuO3SCX3U5AHypuYKS5xRJh3IkIhpMIpJwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537399; c=relaxed/simple; bh=3FZTLXuaU09VVvMBzOjdk8Z8qReFeOFUk3dTmgnFQF8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=svoyuAf/ySrfAb4EpWxSJuq6TiEY84g8y21z5Z2qnjm9LEa74MWptu/PmRyDYo83rtwYfDBCXW0m4S41FBLiK//Aw8tyC+J7Nl8WuEZKPSHuaCEUfUgSm8Enaidc351upsfcQwsA7HVTg1IpJwYNJMBD2mUSqyQmUmgywgx/CsQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=XWsINxQS; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="XWsINxQS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=KJaLSVXi592y0gacfuTTiBm+7QT8qlBLotHuY2MXYgc=; b=XWsINxQSXVyn1U6hRMh2UBaOko JrePQjUQAtEAM8Ja3/9GFOWfEs/yO5H7QuWWGUsBBmlicnA1H88iZRaeD/mWLcBlYivIkoPDBmzUu fviF8GB7kW4Ebx4g5rZLYQSiMQzMEDZsK0xY3VnYB+3FjJJ4Nwvb2AexSUnV9FGXCSvL3XzEB8Lmv FpiENDF+Ygsn91Y2u4DKZhOWTu5YGG9EtSulM95X2eXi/WiqP1Zr1/9/6tWZVz/F1psQ3fCZLbxSl GYVcMNnOQI60jBgH8jmxa4dBZTMK+wheVgNly4vhIZRtXcQn3GrVk9c7cg3/ZEp45Jxe7vsdMsLrZ k5neeIlg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRCNA-00000007zsN-0fQs; Tue, 09 Jul 2024 15:03:16 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 6/7] sysv: Convert sysv_prepare_chunk() to take a folio Date: Tue, 9 Jul 2024 16:03:11 +0100 Message-ID: <20240709150314.1906109-7-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709150314.1906109-1-willy@infradead.org> References: <20240709150314.1906109-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All callers now have a folio, so convert ufs_prepare_chunk() to take one. Signed-off-by: Matthew Wilcox (Oracle) --- fs/sysv/dir.c | 8 ++++---- fs/sysv/itree.c | 4 ++-- fs/sysv/sysv.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 5f91a82a2966..43615b803fee 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -213,7 +213,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) got_it: pos = folio_pos(folio) + offset_in_folio(folio, de); folio_lock(folio); - err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE); + err = sysv_prepare_chunk(folio, pos, SYSV_DIRSIZE); if (err) goto out_unlock; memcpy (de->name, name, namelen); @@ -238,7 +238,7 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct folio *folio) int err; folio_lock(folio); - err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE); + err = sysv_prepare_chunk(folio, pos, SYSV_DIRSIZE); if (err) { folio_unlock(folio); return err; @@ -259,7 +259,7 @@ int sysv_make_empty(struct inode *inode, struct inode *dir) if (IS_ERR(folio)) return PTR_ERR(folio); - err = sysv_prepare_chunk(&folio->page, 0, 2 * SYSV_DIRSIZE); + err = sysv_prepare_chunk(folio, 0, 2 * SYSV_DIRSIZE); if (err) { folio_unlock(folio); goto fail; @@ -335,7 +335,7 @@ int sysv_set_link(struct sysv_dir_entry *de, struct folio *folio, int err; folio_lock(folio); - err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE); + err = sysv_prepare_chunk(folio, pos, SYSV_DIRSIZE); if (err) { folio_unlock(folio); return err; diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c index 19bcb51a2203..c8511e286673 100644 --- a/fs/sysv/itree.c +++ b/fs/sysv/itree.c @@ -466,9 +466,9 @@ static int sysv_read_folio(struct file *file, struct folio *folio) return block_read_full_folio(folio, get_block); } -int sysv_prepare_chunk(struct page *page, loff_t pos, unsigned len) +int sysv_prepare_chunk(struct folio *folio, loff_t pos, unsigned len) { - return __block_write_begin(page, pos, len, get_block); + return __block_write_begin(&folio->page, pos, len, get_block); } static void sysv_write_failed(struct address_space *mapping, loff_t to) diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h index fec9f6b883d5..0a48b2e7edb1 100644 --- a/fs/sysv/sysv.h +++ b/fs/sysv/sysv.h @@ -133,8 +133,8 @@ extern void sysv_free_block(struct super_block *, sysv_zone_t); extern unsigned long sysv_count_free_blocks(struct super_block *); /* itree.c */ -extern void sysv_truncate(struct inode *); -extern int sysv_prepare_chunk(struct page *page, loff_t pos, unsigned len); +void sysv_truncate(struct inode *); +int sysv_prepare_chunk(struct folio *folio, loff_t pos, unsigned len); /* inode.c */ extern struct inode *sysv_iget(struct super_block *, unsigned int); From patchwork Tue Jul 9 15:03:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13728210 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 C0DBF19CCF4 for ; Tue, 9 Jul 2024 15:03:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537399; cv=none; b=Huielhq5i7zDx46VywPMLLDY6M6x3/qunPmp2slzhzvwYy31EX1tIKXnWNQpDOKzg9Wbynn+sMQvMcquEa/v8swg7gy9jP2v4A3Vwv9hjiRUvO5MkW07LV1bj6fWcdIf/xLCvWAab4UmJ0qwRhnsIO+d12GK5fzseM9ENZUTEWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720537399; c=relaxed/simple; bh=OyBH+sUzL68gX3EQvBjAjSq97byxdrgny3BAk/2KBE8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JBPDQw1vKceom1xHUwHj98wLACzDiJZR9ZGJGt2111eE1gbN9ATw3D3F1O7y8GYR5eXOTi63/kbgd1cw21sT0Dk3l7eE3RCG/CjaHkBlVOkCtEXciZD7qsQj2/Urx+nXnMe2Ctr2yX/FZyfb6iDn2i2HrMfGtQkww4/5YN3UEtw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=WaQPiZof; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="WaQPiZof" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Y9NIrT9bGXXaj8ypo8Ee686FddLu/HsImPyUZW8oGMs=; b=WaQPiZoft9dJ14/aFdcvZWBEPO PvRGFRhTDbr9B6p0ueusWCNrejSr1M3E6gsQkpyzs6PU3WSrDcwmD+L8CvAE+0yh7AMtCEmZANiWf oOE3KFCfWSYPILZ+cPwjN1Hwv7UXbobGksL7lNKcUlMirssxvb5hW6tngPORLNIvvjKn0sj5nTm0m 1D2/kRU2YgX6y8+0HNUQOswef7TIrVJTa55WRbKtvftMOhBzV/69rOTIxOhlArUm3LsuDBzpC9L/7 xL6wxhn/BCpg2HoXtvpAl6Dx4S0VDkwdjExJET5yVM5khF37b4aNYcJPJL3/HUeJayPn0tdGJN0jH cOLpX8uQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRCNA-00000007zsU-1AbC; Tue, 09 Jul 2024 15:03:16 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 7/7] sysv: Convert dir_commit_chunk() to take a folio Date: Tue, 9 Jul 2024 16:03:12 +0100 Message-ID: <20240709150314.1906109-8-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709150314.1906109-1-willy@infradead.org> References: <20240709150314.1906109-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All callers now have a folio, so pass it in. Saves a call to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/sysv/dir.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 43615b803fee..27eaa5273ba7 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -28,17 +28,17 @@ const struct file_operations sysv_dir_operations = { .fsync = generic_file_fsync, }; -static void dir_commit_chunk(struct page *page, loff_t pos, unsigned len) +static void dir_commit_chunk(struct folio *folio, loff_t pos, unsigned len) { - struct address_space *mapping = page->mapping; + struct address_space *mapping = folio->mapping; struct inode *dir = mapping->host; - block_write_end(NULL, mapping, pos, len, len, page, NULL); + block_write_end(NULL, mapping, pos, len, len, &folio->page, NULL); if (pos+len > dir->i_size) { i_size_write(dir, pos+len); mark_inode_dirty(dir); } - unlock_page(page); + folio_unlock(folio); } static int sysv_handle_dirsync(struct inode *dir) @@ -219,7 +219,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) memcpy (de->name, name, namelen); memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2); de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); - dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE); + dir_commit_chunk(folio, pos, SYSV_DIRSIZE); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); mark_inode_dirty(dir); err = sysv_handle_dirsync(dir); @@ -244,7 +244,7 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct folio *folio) return err; } de->inode = 0; - dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE); + dir_commit_chunk(folio, pos, SYSV_DIRSIZE); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); mark_inode_dirty(inode); return sysv_handle_dirsync(inode); @@ -275,7 +275,7 @@ int sysv_make_empty(struct inode *inode, struct inode *dir) strcpy(de->name,".."); kunmap_local(kaddr); - dir_commit_chunk(&folio->page, 0, 2 * SYSV_DIRSIZE); + dir_commit_chunk(folio, 0, 2 * SYSV_DIRSIZE); err = sysv_handle_dirsync(inode); fail: folio_put(folio); @@ -341,7 +341,7 @@ int sysv_set_link(struct sysv_dir_entry *de, struct folio *folio, return err; } de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); - dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE); + dir_commit_chunk(folio, pos, SYSV_DIRSIZE); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); mark_inode_dirty(dir); return sysv_handle_dirsync(inode);