From patchwork Tue Jul 9 03:30:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13727230 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 6062464A for ; Tue, 9 Jul 2024 03:30:33 +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=1720495835; cv=none; b=V3TfIbxFfafld/mFfdJ9M38XBbyj4NljJhEnKK3AEUAo2W7kUpozw4XkqotPhSs+PlyLhWm+xXBZ5Jo5knMknXF07P4Qpf3zhQln8tU+OGNagsNErHCtY2tyoxAVJAWNL9J0knvPNiYulHybwIzwLRngjsPpu8n45dnwG9bB1JY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720495835; c=relaxed/simple; bh=8bHZbJId0ovgon4/9AKw2LyS5x+UiiIv5uSOyjTJI+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cKvnXDuakbXciCyJYUtfvFn3gL6BQKd//9xPeSVc+WjDS2YVvCAcUxvdV/25f+8sRwwd3UFtq+KsfkIJJhKKFx6RXnpFxuZiYozVFsvK/qtFP7GGger6f1MXbnpPSssN0XAXoW/mBpxIxXvqNex2LAouMVDFEyQZnrgRwxgs0Go= 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=c/Q9BtEM; 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="c/Q9BtEM" 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=joDbiTqAQWjjgZNLC481R5u1YNLWqgIKDhlOHrSPA7Q=; b=c/Q9BtEMm6X/TU5uYOR85N7Zte gQdQTtdYOesQ+HxKNOQXhGIly21qmkWEKPKbuVx/uOxDkJnx4D9VFJXFsiUg0ZKcrLYaGhreMazPV TXrSfsk1zTyIKIPlMp5pVIf6eyUG+hb9sHDboM3JapD7VRtQAWqqvn+bNrNJs/MUVUfBcKJOCG2ll Wvb0IBF3vWeT+SOHcXwRtDKm0Ar6bOkTVfwB1F1WKq2wVfLn8HomyRDpXvcpMtIOBcAM0Hl31kfJ9 iZk6mILNsUoQpaiIYTlskvsUuxrSKydxrH8Y7s3BwAjmgIGBw8PX3VBOp39FxOV5YeZfJEp2yHv+4 MKIcCvbw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR1Yl-00000007QSX-162W; Tue, 09 Jul 2024 03:30:31 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 01/10] ufs: Convert ufs_get_page() to use a folio Date: Tue, 9 Jul 2024 04:30:18 +0100 Message-ID: <20240709033029.1769992-2-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709033029.1769992-1-willy@infradead.org> References: <20240709033029.1769992-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 call to read_mapping_page(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/ufs/dir.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 61f25d3cf3f7..0705848899c1 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -194,18 +194,19 @@ static bool ufs_check_page(struct page *page) static struct page *ufs_get_page(struct inode *dir, unsigned long n) { struct address_space *mapping = dir->i_mapping; - struct page *page = read_mapping_page(mapping, n, NULL); - if (!IS_ERR(page)) { - kmap(page); - if (unlikely(!PageChecked(page))) { - if (!ufs_check_page(page)) - goto fail; - } + struct folio *folio = read_mapping_folio(mapping, n, NULL); + + if (IS_ERR(folio)) + return &folio->page; + kmap(&folio->page); + if (unlikely(!folio_test_checked(folio))) { + if (!ufs_check_page(&folio->page)) + goto fail; } - return page; + return &folio->page; fail: - ufs_put_page(page); + ufs_put_page(&folio->page); return ERR_PTR(-EIO); } From patchwork Tue Jul 9 03:30:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13727240 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 AE7FE12C46F for ; Tue, 9 Jul 2024 03:30:38 +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=1720495840; cv=none; b=c0TMDXZHPQt7RTD75tJySo3DtlVQtUW3HdQzADc8zRfWnYd2X7WKfZ6rKW68VoWNuSAqevH8uL7mrPOMw2vS1CKEQ9yKbf6pzxg9sLpUF/B89V2P5Qu4EJi0d/wezqmHbAUVNt4hiXTZUKXHd3T/Tla5pFscmYN95lWTcFN6400= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720495840; c=relaxed/simple; bh=DBgN0O7JoPZ1T1KEU2CIXrUGaO+kp1X/FljQucYhgI4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=prq2+fMI7HxgE1BAdNN2iaXEmEOsAwmSKkfYaxWBPryINlODCJTypJ0Fh9PZI630IYzlfOC8WNDJscZoYRKdkAMsL7IJpjRSN+tzw8PCLCtB5s74aOx1TqJ9A6ulSck7B2WDMHqeoI+/NPjIe1yzuDbKVEB4TwB3Ii1y/ZUZDQM= 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=XwhtkTwl; 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="XwhtkTwl" 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=doaouVmAEXZyjb88/tH6NQPtu9oK2glAhgUxzv971OU=; b=XwhtkTwlTL/Roqf9ocXeaQ3/KY r00iaDp0s9+jA7apnm/boh7C8WN9D075KvUt1y6YahfC+XqHbGsHiwk7WawGnEPESmJccaH68+cYv 4nsjpKHW085TKnFwBCzsuoRsC4JcL0nL4VTrdHbCqQwydsf+PCrve01WgUXgHo/wgeLh48XfcqN32 RIbOpFgQKKjrQK8Jl6lxgydgjVECmpafcfm3WADOjH9unMey82i8YMt2BhJT8VlP+JQ1G1d75/lFE sKpsBUSzGW04C4B3QpwnmTQ50Eya02naAj8yCKiybiZr8NCqzgo2ksgUecDsFKkHO9zXjASdLY7aC 968X7FVA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR1Yl-00000007QSZ-1PeS; Tue, 09 Jul 2024 03:30:31 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 02/10] ufs: Convert ufs_get_page() to ufs_get_folio() Date: Tue, 9 Jul 2024 04:30:19 +0100 Message-ID: <20240709033029.1769992-3-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709033029.1769992-1-willy@infradead.org> References: <20240709033029.1769992-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the same calling convention as ext2 (see commit 46022375abe8) so that we can transition to kmap_local in a future patch. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ufs/dir.c | 101 ++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 0705848899c1..6c3235f426ed 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -191,19 +191,22 @@ static bool ufs_check_page(struct page *page) return false; } -static struct page *ufs_get_page(struct inode *dir, unsigned long n) +static void *ufs_get_folio(struct inode *dir, unsigned long n, + struct folio **foliop) { struct address_space *mapping = dir->i_mapping; struct folio *folio = read_mapping_folio(mapping, n, NULL); + void *kaddr; if (IS_ERR(folio)) - return &folio->page; - kmap(&folio->page); + return ERR_CAST(folio); + kaddr = kmap(&folio->page); if (unlikely(!folio_test_checked(folio))) { if (!ufs_check_page(&folio->page)) goto fail; } - return &folio->page; + *foliop = folio; + return kaddr; fail: ufs_put_page(&folio->page); @@ -234,14 +237,14 @@ ufs_next_entry(struct super_block *sb, struct ufs_dir_entry *p) struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p) { - struct page *page = ufs_get_page(dir, 0); - struct ufs_dir_entry *de = NULL; + struct folio *folio; + struct ufs_dir_entry *de = ufs_get_folio(dir, 0, &folio); + + if (IS_ERR(de)) + return NULL; + de = ufs_next_entry(dir->i_sb, de); + *p = &folio->page; - if (!IS_ERR(page)) { - de = ufs_next_entry(dir->i_sb, - (struct ufs_dir_entry *)page_address(page)); - *p = page; - } return de; } @@ -262,7 +265,7 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, unsigned reclen = UFS_DIR_REC_LEN(namelen); unsigned long start, n; unsigned long npages = dir_pages(dir); - struct page *page = NULL; + struct folio *folio; struct ufs_inode_info *ui = UFS_I(dir); struct ufs_dir_entry *de; @@ -280,18 +283,17 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, start = 0; n = start; do { - char *kaddr; - page = ufs_get_page(dir, n); - if (!IS_ERR(page)) { - kaddr = page_address(page); - de = (struct ufs_dir_entry *) kaddr; + char *kaddr = ufs_get_folio(dir, n, &folio); + + if (!IS_ERR(kaddr)) { + de = (struct ufs_dir_entry *)kaddr; kaddr += ufs_last_byte(dir, n) - reclen; while ((char *) de <= kaddr) { if (ufs_match(sb, namelen, name, de)) goto found; de = ufs_next_entry(sb, de); } - ufs_put_page(page); + ufs_put_page(&folio->page); } if (++n >= npages) n = 0; @@ -300,7 +302,7 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, return NULL; found: - *res_page = page; + *res_page = &folio->page; ui->i_dir_start_lookup = n; return de; } @@ -317,11 +319,10 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) unsigned reclen = UFS_DIR_REC_LEN(namelen); const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize; unsigned short rec_len, name_len; - struct page *page = NULL; + struct folio *folio = NULL; struct ufs_dir_entry *de; unsigned long npages = dir_pages(dir); unsigned long n; - char *kaddr; loff_t pos; int err; @@ -329,21 +330,19 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) /* * We take care of directory expansion in the same loop. - * This code plays outside i_size, so it locks the page + * This code plays outside i_size, so it locks the folio * to protect that region. */ for (n = 0; n <= npages; n++) { + char *kaddr = ufs_get_folio(dir, n, &folio); char *dir_end; - page = ufs_get_page(dir, n); - err = PTR_ERR(page); - if (IS_ERR(page)) - goto out; - lock_page(page); - kaddr = page_address(page); + if (IS_ERR(kaddr)) + return PTR_ERR(kaddr); + folio_lock(folio); dir_end = kaddr + ufs_last_byte(dir, n); de = (struct ufs_dir_entry *)kaddr; - kaddr += PAGE_SIZE - reclen; + kaddr += folio_size(folio) - reclen; while ((char *)de <= kaddr) { if ((char *)de == dir_end) { /* We hit i_size */ @@ -370,16 +369,15 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) goto got_it; de = (struct ufs_dir_entry *) ((char *) de + rec_len); } - unlock_page(page); - ufs_put_page(page); + folio_unlock(folio); + ufs_put_page(&folio->page); } BUG(); return -EINVAL; got_it: - pos = page_offset(page) + - (char*)de - (char*)page_address(page); - err = ufs_prepare_chunk(page, pos, rec_len); + pos = folio_pos(folio) + offset_in_folio(folio, de); + err = ufs_prepare_chunk(&folio->page, pos, rec_len); if (err) goto out_unlock; if (de->d_ino) { @@ -396,18 +394,17 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) de->d_ino = cpu_to_fs32(sb, inode->i_ino); ufs_set_de_type(sb, de, inode->i_mode); - ufs_commit_chunk(page, pos, rec_len); + ufs_commit_chunk(&folio->page, pos, rec_len); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); mark_inode_dirty(dir); err = ufs_handle_dirsync(dir); /* OFFSET_CACHE */ out_put: - ufs_put_page(page); -out: + ufs_put_page(&folio->page); return err; out_unlock: - unlock_page(page); + folio_unlock(folio); goto out_put; } @@ -445,19 +442,18 @@ ufs_readdir(struct file *file, struct dir_context *ctx) return 0; for ( ; n < npages; n++, offset = 0) { - char *kaddr, *limit; struct ufs_dir_entry *de; + struct folio *folio; + char *kaddr = ufs_get_folio(inode, n, &folio); + char *limit; - struct page *page = ufs_get_page(inode, n); - - if (IS_ERR(page)) { + if (IS_ERR(kaddr)) { ufs_error(sb, __func__, "bad page in #%lu", inode->i_ino); ctx->pos += PAGE_SIZE - offset; - return -EIO; + return PTR_ERR(kaddr); } - kaddr = page_address(page); if (unlikely(need_revalidate)) { if (offset) { offset = ufs_validate_entry(sb, kaddr, offset, chunk_mask); @@ -483,13 +479,13 @@ ufs_readdir(struct file *file, struct dir_context *ctx) ufs_get_de_namlen(sb, de), fs32_to_cpu(sb, de->d_ino), d_type)) { - ufs_put_page(page); + ufs_put_page(&folio->page); return 0; } } ctx->pos += fs16_to_cpu(sb, de->d_reclen); } - ufs_put_page(page); + ufs_put_page(&folio->page); } return 0; } @@ -600,18 +596,17 @@ int ufs_make_empty(struct inode * inode, struct inode *dir) int ufs_empty_dir(struct inode * inode) { struct super_block *sb = inode->i_sb; - struct page *page = NULL; + struct folio *folio; + char *kaddr; unsigned long i, npages = dir_pages(inode); for (i = 0; i < npages; i++) { - char *kaddr; struct ufs_dir_entry *de; - page = ufs_get_page(inode, i); - if (IS_ERR(page)) + kaddr = ufs_get_folio(inode, i, &folio); + if (IS_ERR(kaddr)) continue; - kaddr = page_address(page); de = (struct ufs_dir_entry *)kaddr; kaddr += ufs_last_byte(inode, i) - UFS_DIR_REC_LEN(1); @@ -638,12 +633,12 @@ int ufs_empty_dir(struct inode * inode) } de = ufs_next_entry(sb, de); } - ufs_put_page(page); + ufs_put_page(&folio->page); } return 1; not_empty: - ufs_put_page(page); + ufs_put_page(&folio->page); return 0; } From patchwork Tue Jul 9 03:30:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13727238 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 606EA38F91 for ; Tue, 9 Jul 2024 03:30:33 +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=1720495837; cv=none; b=Sk9KhIsbam6HSrtwvFAol03p4cXrkzwHnMiCnh8sWKBnv3l6ZeYoD/f/OT9qdGihzj/bh09vVSl/fZcFLwuZpBA1v6XCU2wPIpIzhDpNky6Y0WG5BMlgOFgVt6NL006A2uK+Ylu3WgXB+ZHiEw45nU/5qCuqRXtHFE2DXhyOA/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720495837; c=relaxed/simple; bh=6bXTYSNU9a9xY1F8Ofw/bhzGActM9dRbRzvxjMyJdrQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YhYDj/DQxF14fesmp2jopp2eD2q98yNkQSxBUxxv5RzVluj6sA2Z/TPburOuOYzvKdwOKRVVZQMxA4PPq6A78KzMHMGaE8SBcLRaC5dVKLTlXJHDDdyDYwOshqk5/BGxKHusCS/smcFByT1oSToL6yY2Sc27SNGk4ngGnZkgdOM= 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=i+Wa7Eat; 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="i+Wa7Eat" 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=Z1IDe8LZftlaTrVrHQC0emAEo4+quFPohWu0JQ9EECQ=; b=i+Wa7EatLnGPfrzzh1PB1cfJV6 f00A1RLRD1Yk2QzH85Dyesiq9oRf52u1xH1ZUhIYVBuCM5FNVKKkhmdKeTj9t95FjUDdJMpWiudHI lWrn1yiw88+n+uOtLlMdC2mUSV1+7PR31oS3Jep+r+JNIuVnuPrNlstzEK/Zm31KrIecSxz9PElLG 2KGX51VhzgJaj9SJ/LWDFqEa0rHyIX2JuLdRGmWd4a7UIHnOMSafb0nkQYSq/bii6t9RNtKoYe1CI WY9j+aTk1iQ6Clp2XlsQYimsMnmIu/xK1NByR0CAbbxssAfaDzH7MX9y7rOOuBXXBNGHdKbo6K9EW fUdd6R7A==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR1Yl-00000007QSb-1luG; Tue, 09 Jul 2024 03:30:31 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 03/10] ufs: Convert ufs_check_page() to ufs_check_folio() Date: Tue, 9 Jul 2024 04:30:20 +0100 Message-ID: <20240709033029.1769992-4-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709033029.1769992-1-willy@infradead.org> References: <20240709033029.1769992-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Includes large folio support in case we decide to support block size > PAGE_SIZE (as with ext2, this support will be limited to machines without HIGHMEM). --- fs/ufs/dir.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 6c3235f426ed..287cab597cc1 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -112,20 +112,18 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, ufs_handle_dirsync(dir); } - -static bool ufs_check_page(struct page *page) +static bool ufs_check_folio(struct folio *folio, char *kaddr) { - struct inode *dir = page->mapping->host; + struct inode *dir = folio->mapping->host; struct super_block *sb = dir->i_sb; - char *kaddr = page_address(page); unsigned offs, rec_len; - unsigned limit = PAGE_SIZE; + unsigned limit = folio_size(folio); const unsigned chunk_mask = UFS_SB(sb)->s_uspi->s_dirblksize - 1; struct ufs_dir_entry *p; char *error; - if ((dir->i_size >> PAGE_SHIFT) == page->index) { - limit = dir->i_size & ~PAGE_MASK; + if (dir->i_size < folio_pos(folio) + limit) { + limit = offset_in_folio(folio, dir->i_size); if (limit & chunk_mask) goto Ebadsize; if (!limit) @@ -150,13 +148,13 @@ static bool ufs_check_page(struct page *page) if (offs != limit) goto Eend; out: - SetPageChecked(page); + folio_set_checked(folio); return true; /* Too bad, we had an error */ Ebadsize: - ufs_error(sb, "ufs_check_page", + ufs_error(sb, __func__, "size of directory #%lu is not a multiple of chunk size", dir->i_ino ); @@ -176,17 +174,17 @@ static bool ufs_check_page(struct page *page) Einumber: error = "inode out of bounds"; bad_entry: - ufs_error (sb, "ufs_check_page", "bad entry in directory #%lu: %s - " - "offset=%lu, rec_len=%d, name_len=%d", - dir->i_ino, error, (page->index<i_ino, error, folio_pos(folio) + offs, rec_len, ufs_get_de_namlen(sb, p)); goto fail; Eend: p = (struct ufs_dir_entry *)(kaddr + offs); ufs_error(sb, __func__, "entry in directory #%lu spans the page boundary" - "offset=%lu", - dir->i_ino, (page->index<i_ino, folio_pos(folio) + offs); fail: return false; } @@ -202,7 +200,7 @@ static void *ufs_get_folio(struct inode *dir, unsigned long n, return ERR_CAST(folio); kaddr = kmap(&folio->page); if (unlikely(!folio_test_checked(folio))) { - if (!ufs_check_page(&folio->page)) + if (!ufs_check_folio(folio, kaddr)) goto fail; } *foliop = folio; From patchwork Tue Jul 9 03:30:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13727232 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 60659A21 for ; Tue, 9 Jul 2024 03:30:33 +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=1720495835; cv=none; b=DFFCpXRKfNly708zje0R4zPFDM8QpqZdYEqiCdkof51sgVrEdV/INV+NNsForavRuD2M7fcoaKgk86xzwe6JFWSOpMI8b2A1Puso9uHMUAqHB05R7ntST8utFQ+WB8aRuEXf46FwOPWItXK3fpKqhHCHVg0INaaHQSyrkoAfLYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720495835; c=relaxed/simple; bh=wSgAdKCZVERH9++pxvVYTnzVoL7awE6dEBYb1MVz5+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X6foZJN3b9QfD1x59aiRULUcWyZKy53q3F4Xmais4hKqpfrlzgjRbYu8sgwHx8eF+arX51/Gv5dzppeJcIxhcWiKbO7gO3kSDakwwoqRGS+g1z6RfcjCtzHeVLe+PvD7NGTl0qUkBz3TE+3e7CV3TXW7sVS0m9L3UY6kmF+2lEc= 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=I7Yh/07Y; 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="I7Yh/07Y" 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=F9Hhwuu9VH/xpU90hmF/lviEiO2kLB3Vqv+u/0gFbpk=; b=I7Yh/07YebnBUBuos5KuZwlAPY 3mLCHJCYu9TGDPD90Gax45UGDqIV2+5hXqgSW4yWA5Pyaadcvp1/J3WUJyF/OMJwppdkKzZRPCmFu LosozNoB8X2DQV0lRzP+TkphMroXIn2B8872LI/kZLx1zAaCpAiemqacNZSAznU0jbG7CS0YCZd0G HPMt/BOjWykfqmRO8Flv5uK7d8dDr+5qzbN/4qIxTIfJlJVBKpAzz42KP35GUoJVBbBR98Kujwi/D DI/QYmT0c/A5AxyzqCZ6Cds6J+AEfBem1m3rd9RxqQn0SWnkr5BPOR4BD/tFS3eVT5Kgrn3hjsm1H ogrGQ+pw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR1Yl-00000007QSk-2KSu; Tue, 09 Jul 2024 03:30:31 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 04/10] ufs: Convert ufs_find_entry() to take a folio Date: Tue, 9 Jul 2024 04:30:21 +0100 Message-ID: <20240709033029.1769992-5-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709033029.1769992-1-willy@infradead.org> References: <20240709033029.1769992-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 pushes the use of folios out by one layer. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ufs/dir.c | 17 ++++++----------- fs/ufs/namei.c | 22 +++++++++++----------- fs/ufs/ufs.h | 20 +++++++++++--------- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 287cab597cc1..fb56a00b622c 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -76,12 +76,12 @@ ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr) { ino_t res = 0; struct ufs_dir_entry *de; - struct page *page; + struct folio *folio; - de = ufs_find_entry(dir, qstr, &page); + de = ufs_find_entry(dir, qstr, &folio); if (de) { res = fs32_to_cpu(dir->i_sb, de->d_ino); - ufs_put_page(page); + ufs_put_page(&folio->page); } return res; } @@ -255,7 +255,7 @@ struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p) * Entry is guaranteed to be valid. */ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, - struct page **res_page) + struct folio **foliop) { struct super_block *sb = dir->i_sb; const unsigned char *name = qstr->name; @@ -263,7 +263,6 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, unsigned reclen = UFS_DIR_REC_LEN(namelen); unsigned long start, n; unsigned long npages = dir_pages(dir); - struct folio *folio; struct ufs_inode_info *ui = UFS_I(dir); struct ufs_dir_entry *de; @@ -272,16 +271,13 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, if (npages == 0 || namelen > UFS_MAXNAMLEN) goto out; - /* OFFSET_CACHE */ - *res_page = NULL; - start = ui->i_dir_start_lookup; if (start >= npages) start = 0; n = start; do { - char *kaddr = ufs_get_folio(dir, n, &folio); + char *kaddr = ufs_get_folio(dir, n, foliop); if (!IS_ERR(kaddr)) { de = (struct ufs_dir_entry *)kaddr; @@ -291,7 +287,7 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, goto found; de = ufs_next_entry(sb, de); } - ufs_put_page(&folio->page); + ufs_put_page(&(*foliop)->page); } if (++n >= npages) n = 0; @@ -300,7 +296,6 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, return NULL; found: - *res_page = &folio->page; ui->i_dir_start_lookup = n; return de; } diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index 9cad29463791..53e9bfad54df 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c @@ -209,14 +209,14 @@ static int ufs_unlink(struct inode *dir, struct dentry *dentry) { struct inode * inode = d_inode(dentry); struct ufs_dir_entry *de; - struct page *page; + struct folio *folio; int err = -ENOENT; - de = ufs_find_entry(dir, &dentry->d_name, &page); + de = ufs_find_entry(dir, &dentry->d_name, &folio); if (!de) goto out; - err = ufs_delete_entry(dir, de, page); + err = ufs_delete_entry(dir, de, &folio->page); if (err) goto out; @@ -251,14 +251,14 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, struct inode *new_inode = d_inode(new_dentry); struct page *dir_page = NULL; struct ufs_dir_entry * dir_de = NULL; - struct page *old_page; + struct folio *old_folio; struct ufs_dir_entry *old_de; int err = -ENOENT; if (flags & ~RENAME_NOREPLACE) return -EINVAL; - old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page); + old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_folio); if (!old_de) goto out; @@ -270,7 +270,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, } if (new_inode) { - struct page *new_page; + struct folio *new_folio; struct ufs_dir_entry *new_de; err = -ENOTEMPTY; @@ -278,10 +278,10 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, goto out_dir; err = -ENOENT; - new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_page); + 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_page, old_inode, 1); + ufs_set_link(new_dir, new_de, &new_folio->page, old_inode, 1); inode_set_ctime_current(new_inode); if (dir_de) drop_nlink(new_inode); @@ -300,7 +300,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, */ inode_set_ctime_current(old_inode); - ufs_delete_entry(old_dir, old_de, old_page); + ufs_delete_entry(old_dir, old_de, &old_folio->page); mark_inode_dirty(old_inode); if (dir_de) { @@ -321,8 +321,8 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, put_page(dir_page); } out_old: - kunmap(old_page); - put_page(old_page); + kunmap(&old_folio->page); + folio_put(old_folio); out: return err; } diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index 6b499180643b..161fe0bb6fd1 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h @@ -99,15 +99,17 @@ extern void ufs_put_cylinder (struct super_block *, unsigned); /* dir.c */ extern const struct inode_operations ufs_dir_inode_operations; -extern int ufs_add_link (struct dentry *, struct inode *); -extern ino_t ufs_inode_by_name(struct inode *, const struct qstr *); -extern int ufs_make_empty(struct inode *, struct inode *); -extern struct ufs_dir_entry *ufs_find_entry(struct inode *, const struct qstr *, struct page **); -extern int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page *); -extern int ufs_empty_dir (struct inode *); -extern struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **); -extern void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, - struct page *page, struct inode *inode, bool update_times); + +int ufs_add_link(struct dentry *, struct inode *); +ino_t ufs_inode_by_name(struct inode *, const struct qstr *); +int ufs_make_empty(struct inode *, struct inode *); +struct ufs_dir_entry *ufs_find_entry(struct inode *, const struct qstr *, + struct folio **); +int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page *); +int ufs_empty_dir(struct inode *); +struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **); +void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, + struct page *page, struct inode *inode, bool update_times); /* file.c */ extern const struct inode_operations ufs_file_inode_operations; From patchwork Tue Jul 9 03:30:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13727234 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 606BD2772A for ; Tue, 9 Jul 2024 03:30:33 +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=1720495836; cv=none; b=On80ObAzEXwy+B81mWVWz8tZOeRfnQrui2/VcvXFa4Qi5bH15E2MVYCJR+NmLF5BDe8d3jAMZGEK5FD7c9yFYPO09a2fy/JUve/fpX0xqp7tUjOd4UC2wNZmYhK9r5CgeOqYyNXP3gSvvVtK+38vgi2TMk8sg2IdQY5MscXeOis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720495836; c=relaxed/simple; bh=AY9j6OD8TiMWAQJqPlJ4/9k3HnM0gtNtNQ4nqoqeMhI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rCtTeEaiFZIkdcxaUf6FQSlgXJEo3AooR78Cm+aIVtJHAYzG3+vSzWYScq134LI+Xn6jZf84Fds+9J+p4xWc6KxHVnj2IBRVnPjuDM0f/fZik+7Soubm7m+mQKssat8tJ//ulflWmZx9Hn/8qEbj1QWZHaM6q97hpKzh16Chygs= 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=GVEDGV43; 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="GVEDGV43" 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=dMl8wa5hGk6WVrF+XRUm3H21k6p6e6atwRzzEhlEt1E=; b=GVEDGV43o9FF5BnOUsodjZzvFe gFtvw1iqhbnqRmlUtSnPyrdhKTURxO/Yo1s+gvdLSe/rGCIebyvcbQ00KqwOKPaC7LyhhX1rIJ200 3IBfR0tVh0kn6qMQyMWgxQ9oKc0Y2kI03+wIXmdng7KYrAkHcRFu6hwO42f1N1aunmuINO1cpRC7g br5WPZRivI803KMt3yqkl7fAOnMeLo746KyLWFvVvwzSkw43QnreT6UZCd6RYpiUVQRF8Z4MwULaL F6rWFbjqfDaMpJEUTP57bddHRBEKzpD8HCLPlq9wbM9uiY3KQcFyEMAS1n6989G3oag3SDd0J/tBH 2mI8ZPXg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR1Yl-00000007QSr-2tTY; Tue, 09 Jul 2024 03:30:31 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 05/10] ufs: Convert ufs_set_link() and ufss_dotdot() to take a folio Date: Tue, 9 Jul 2024 04:30:22 +0100 Message-ID: <20240709033029.1769992-6-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709033029.1769992-1-willy@infradead.org> References: <20240709033029.1769992-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/ufs/dir.c | 26 +++++++++++--------------- fs/ufs/namei.c | 16 ++++++++-------- fs/ufs/ufs.h | 4 ++-- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index fb56a00b622c..6fcca4dd064a 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -89,23 +89,22 @@ 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 page *page, struct inode *inode, + struct folio *folio, struct inode *inode, bool update_times) { - loff_t pos = page_offset(page) + - (char *) de - (char *) page_address(page); + loff_t pos = folio_pos(folio) + offset_in_folio(folio, de); unsigned len = fs16_to_cpu(dir->i_sb, de->d_reclen); int err; - lock_page(page); - err = ufs_prepare_chunk(page, pos, len); + folio_lock(folio); + err = ufs_prepare_chunk(&folio->page, pos, len); BUG_ON(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(page, pos, len); - ufs_put_page(page); + ufs_commit_chunk(&folio->page, pos, len); + ufs_put_page(&folio->page); if (update_times) inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); mark_inode_dirty(dir); @@ -233,17 +232,14 @@ ufs_next_entry(struct super_block *sb, struct ufs_dir_entry *p) fs16_to_cpu(sb, p->d_reclen)); } -struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p) +struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct folio **foliop) { - struct folio *folio; - struct ufs_dir_entry *de = ufs_get_folio(dir, 0, &folio); + struct ufs_dir_entry *de = ufs_get_folio(dir, 0, foliop); - if (IS_ERR(de)) - return NULL; - de = ufs_next_entry(dir->i_sb, de); - *p = &folio->page; + if (!IS_ERR(de)) + return ufs_next_entry(dir->i_sb, de); - return de; + return NULL; } /* diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index 53e9bfad54df..1759b710d831 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c @@ -249,7 +249,7 @@ static int ufs_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 = NULL; struct ufs_dir_entry * dir_de = NULL; struct folio *old_folio; struct ufs_dir_entry *old_de; @@ -264,7 +264,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, if (S_ISDIR(old_inode->i_mode)) { err = -EIO; - dir_de = ufs_dotdot(old_inode, &dir_page); + dir_de = ufs_dotdot(old_inode, &dir_folio); if (!dir_de) goto out_old; } @@ -281,7 +281,7 @@ 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->page, old_inode, 1); + ufs_set_link(new_dir, new_de, new_folio, old_inode, 1); inode_set_ctime_current(new_inode); if (dir_de) drop_nlink(new_inode); @@ -305,10 +305,10 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, if (dir_de) { if (old_dir != new_dir) - ufs_set_link(old_inode, dir_de, dir_page, new_dir, 0); + ufs_set_link(old_inode, dir_de, dir_folio, new_dir, 0); else { - kunmap(dir_page); - put_page(dir_page); + kunmap(&dir_folio->page); + folio_put(dir_folio); } inode_dec_link_count(old_dir); } @@ -317,8 +317,8 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, out_dir: if (dir_de) { - kunmap(dir_page); - put_page(dir_page); + kunmap(&dir_folio->page); + folio_put(dir_folio); } out_old: kunmap(&old_folio->page); diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index 161fe0bb6fd1..1ad992ab2855 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h @@ -107,9 +107,9 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *, const struct qstr *, struct folio **); int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page *); int ufs_empty_dir(struct inode *); -struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **); +struct ufs_dir_entry *ufs_dotdot(struct inode *, struct folio **); void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, - struct page *page, struct inode *inode, bool update_times); + struct folio *folio, struct inode *inode, bool update_times); /* file.c */ extern const struct inode_operations ufs_file_inode_operations; From patchwork Tue Jul 9 03:30:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13727235 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 60685849C for ; Tue, 9 Jul 2024 03:30:33 +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=1720495836; cv=none; b=DPYJEh57jvNwhFJfbdjeX7s3s/Ud8mw5lm6CB/mP94sr8iCSJNaKS4IQYe/V4yUdHcNKkMCKE0uqobXXdM8sUVHI2/XXTk3/pk2TJcZhp9j1874Z4YR2XQB0i2yXgvxgry3v4pXCevMg4i6ebUrivdgXA+Knxe4DokHLE7TGg/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720495836; c=relaxed/simple; bh=67hxrAtFvOWGIJAYRGolctFyKYVySX3pIW8gqzasJ3w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jfelSEtb0LlaO6twnNNXEzPRa1ImsJt54aj6lAcQKvl6CqgnYpBGgRzGhDInbPmFNUdCrHtQN6wRu9TeQ9wGKTGjQgJPoDFZlpezFj03VP8Mcw2mHAdA4gO1DhLS3nb0idyG1GKsNzLM9IbeaW0iJ68pUDzTJ//eKJT3rNRUp5A= 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=G/BXDjDt; 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="G/BXDjDt" 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=wiPlt8CPgEZD6LleA4Arv3XM/aGWZNuxt60+mAY9AsM=; b=G/BXDjDtvVWFwR0RZAT66X0dS9 pN7Zcd+2ip031W7OJgfk+TSeYmCyrOgNDCo6gVBVwP61othdVH+0k0RLh7mQvLhmg0EY8JogL+hSW /UuYdtyTN/IrqaTeCno/1dhIoJ5fvUpS8k/cVRp6pTJusGcGdLhehbEtNMBDGcC2sl2QX7HZRpHhJ FDFO2HEYqw5lldcsKDwf6Jz4U6FV0vmrt6uvcEgTrBKOxCt0c6WYrgM4U+mRuy42SfUKPQrd/3jPX hFlCFvCzyyP2lUS/69yyU8T+dAeHBBlzoKwr445+qcAXtOdtkcakpD1tivsiyOTtUEK5CVrJpw/lS IxeYGq0Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR1Yl-00000007QSy-3M7V; Tue, 09 Jul 2024 03:30:31 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 06/10] ufs: Convert ufs_delete_entry() to work on a folio Date: Tue, 9 Jul 2024 04:30:23 +0100 Message-ID: <20240709033029.1769992-7-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709033029.1769992-1-willy@infradead.org> References: <20240709033029.1769992-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/ufs/dir.c | 29 ++++++++++++++++------------- fs/ufs/namei.c | 4 ++-- fs/ufs/ufs.h | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 6fcca4dd064a..945fff87b385 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -485,19 +485,23 @@ ufs_readdir(struct file *file, struct dir_context *ctx) * previous entry. */ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, - struct page * page) + struct folio *folio) { struct super_block *sb = inode->i_sb; - char *kaddr = page_address(page); - unsigned from = ((char*)dir - kaddr) & ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1); - unsigned to = ((char*)dir - kaddr) + fs16_to_cpu(sb, dir->d_reclen); + size_t from, to; + char *kaddr; loff_t pos; - struct ufs_dir_entry *pde = NULL; - struct ufs_dir_entry *de = (struct ufs_dir_entry *) (kaddr + from); + struct ufs_dir_entry *de, *pde = NULL; int err; UFSD("ENTER\n"); + from = offset_in_folio(folio, dir); + to = from + fs16_to_cpu(sb, dir->d_reclen); + kaddr = (char *)dir - from; + from &= ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1); + de = (struct ufs_dir_entry *) (kaddr + from); + UFSD("ino %u, reclen %u, namlen %u, name %s\n", fs32_to_cpu(sb, de->d_ino), fs16_to_cpu(sb, de->d_reclen), @@ -514,21 +518,20 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, de = ufs_next_entry(sb, de); } if (pde) - from = (char*)pde - (char*)page_address(page); - - pos = page_offset(page) + from; - lock_page(page); - err = ufs_prepare_chunk(page, pos, to - from); + from = offset_in_folio(folio, pde); + pos = folio_pos(folio) + from; + folio_lock(folio); + err = ufs_prepare_chunk(&folio->page, pos, to - from); BUG_ON(err); if (pde) pde->d_reclen = cpu_to_fs16(sb, to - from); dir->d_ino = 0; - ufs_commit_chunk(page, pos, to - from); + ufs_commit_chunk(&folio->page, pos, to - from); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); mark_inode_dirty(inode); err = ufs_handle_dirsync(inode); out: - ufs_put_page(page); + ufs_put_page(&folio->page); UFSD("EXIT\n"); return err; } diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index 1759b710d831..a9b0c15de067 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c @@ -216,7 +216,7 @@ static int ufs_unlink(struct inode *dir, struct dentry *dentry) if (!de) goto out; - err = ufs_delete_entry(dir, de, &folio->page); + err = ufs_delete_entry(dir, de, folio); if (err) goto out; @@ -300,7 +300,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, */ inode_set_ctime_current(old_inode); - ufs_delete_entry(old_dir, old_de, &old_folio->page); + ufs_delete_entry(old_dir, old_de, old_folio); mark_inode_dirty(old_inode); if (dir_de) { diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index 1ad992ab2855..a2c762cb65a0 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h @@ -105,7 +105,7 @@ ino_t ufs_inode_by_name(struct inode *, const struct qstr *); int ufs_make_empty(struct inode *, struct inode *); struct ufs_dir_entry *ufs_find_entry(struct inode *, const struct qstr *, struct folio **); -int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page *); +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, From patchwork Tue Jul 9 03:30:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13727231 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 BC2AC3D967 for ; Tue, 9 Jul 2024 03:30:33 +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=1720495835; cv=none; b=L9EBFFnmCHirK98rfx7Iz7tz47wS+/T7dLOBZ4UgLuQWXsdp+6eRL5oCnaiGLECxT73l8bH18FbLUx/FohJcRUPe6eTzpV/2XLQcU0Udd5TVJriV0i9hwN926vWVJP5RdQLzX4nDy8lpIrf5eFoOrDoVIC9BMFYhnCeebmfl2dI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720495835; c=relaxed/simple; bh=CsIqmpYepm4UiYPMuZGOjq57L4rqPZCj517FGlQvLtg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BcBfkdMRMLQ/SRz9wIr2NSZFy8ehYUURTZaANBtQKQRPbCOCcMhJJ9Em0aRWWZtMGKlMEX/EKrRbqTG9QaFRPJ8SHW3GTJGiwxal6sJIZsu7rcbUGTujZb49NQXOcAusQp7MXSht9e5IvBkm+GWWTxglgTVRV+vkKCmYwBLCX3g= 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=bmpwWXi/; 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="bmpwWXi/" 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=qa8AdhGyPjH1Ox5kVghfn0l/IChUPGHUxpys1+/5xT8=; b=bmpwWXi/oCvw6dUU6tDdlFnPPm FxPyNVFuLrg8AyuvB1U6hLgmADtsH/0PPPG00wDR5NHouOnhLec7/o2zequA2y+VQK6KFNkCZutpq QCNgNkLpYVvygNtTlBLzjYxxnps8aIXhspXu9s5fj+QWWnrvqbjPp9Bp8CfkCsgvoXGBo8lCEjQRY xFWeVZsydQ665d7PikNkN5GIjOMtaH2JALUom2daYpdfbeJ6uGMxf7ePxyJ3Fx6zg+XgeU3QsJ6KW dp8FhVv0mcBUZyo6ft+EUG1US0iEdIDrTByYIAJDtUq+Cns43T+7ZruMM+HD/XCsyV5GkteYPL/tL 5kQdgA5Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR1Yl-00000007QT5-3xUN; Tue, 09 Jul 2024 03:30:32 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 07/10] ufs: Convert ufs_make_empty() to use a folio Date: Tue, 9 Jul 2024 04:30:24 +0100 Message-ID: <20240709033029.1769992-8-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709033029.1769992-1-willy@infradead.org> References: <20240709033029.1769992-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() and uses kmap_local instead of kmap. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ufs/dir.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 945fff87b385..6a2a6af38097 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -540,26 +540,25 @@ int ufs_make_empty(struct inode * inode, struct inode *dir) { struct super_block * sb = dir->i_sb; struct address_space *mapping = inode->i_mapping; - struct page *page = grab_cache_page(mapping, 0); + struct folio *folio = filemap_grab_folio(mapping, 0); const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize; struct ufs_dir_entry * de; - char *base; int err; + char *kaddr; - if (!page) - return -ENOMEM; + if (IS_ERR(folio)) + return PTR_ERR(folio); - err = ufs_prepare_chunk(page, 0, chunk_size); + err = ufs_prepare_chunk(&folio->page, 0, chunk_size); if (err) { - unlock_page(page); + folio_unlock(folio); goto fail; } - kmap(page); - base = (char*)page_address(page); - memset(base, 0, PAGE_SIZE); + kaddr = kmap_local_folio(folio, 0); + memset(kaddr, 0, folio_size(folio)); - de = (struct ufs_dir_entry *) base; + de = (struct ufs_dir_entry *)kaddr; de->d_ino = cpu_to_fs32(sb, inode->i_ino); ufs_set_de_type(sb, de, inode->i_mode); @@ -573,12 +572,12 @@ int ufs_make_empty(struct inode * inode, struct inode *dir) de->d_reclen = cpu_to_fs16(sb, chunk_size - UFS_DIR_REC_LEN(1)); ufs_set_de_namlen(sb, de, 2); strcpy (de->d_name, ".."); - kunmap(page); + kunmap_local(kaddr); - ufs_commit_chunk(page, 0, chunk_size); + ufs_commit_chunk(&folio->page, 0, chunk_size); err = ufs_handle_dirsync(inode); fail: - put_page(page); + folio_put(folio); return err; } From patchwork Tue Jul 9 03:30:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13727237 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 BC2FE3F8F7 for ; Tue, 9 Jul 2024 03:30:33 +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=1720495836; cv=none; b=DJ2yQZqAM8iXKTG5oCoOIwo2GyHf5RzdH58kJVxTtrWhHFffD3rqPbffZhonssKXcnUclnodTyM3c8IXAel2u95KPKrAYcpMfkO67fz3YQ8vWmMF2sykJu2WBsG2x4iPc1Im8T9hToV8MMzknqW0nASh0U+/EUNaTgIrA5K7Qz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720495836; c=relaxed/simple; bh=q5XiBYShJOj8iEVsUlhAk9Oxfx1Gqb8GjxB96kAFvFo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R2k8E/nEPfaz4CtYmsUp/llhoIJINMYPBCVOLi8LG44V0quYxxBpGOgBJHcEfP86kktiVeRCm32nSBFNjjom8ZS6h1drGv2ScuFm2jrPMbWCLEapF4c03MGif2z3ybkLeGeT/eMkw7n1Wt4SJjpYUxCPFn92O/rU5viA3AdIY10= 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=IwYJeKB+; 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="IwYJeKB+" 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=EmYbS0CiXqHPOHjcs6k7/ZqcK5mONyvKXbw41+0DSnk=; b=IwYJeKB+9QnDuIQllkXtXD2saE o3L4Yihd65GSqeJBIbUOGvD4X4EDJ7Z5P1MhFmxNnXUZeGJiA0XwjOQcZyXQyELSg1GUhIZ093uAG tBOt+bZCQyNCTWZ008WK6e/7ebncZADnU1CQ8bDPerCc1kLu5WZL3iGGM13jGg5Cd4HvJxcsJKUdy DzIHi8TdK1UDmfGrsXsfhkzvJYhuyXD3ODh114zJwp3COZEuOr7ziNW5Z0yrO5m7L27LJku7YUNDe j0jpIuXHhqp4U0g2B5NizlSERpqze39I8n/09ud5xkVGBJAObO7C/d+Dd5rxLAsZah0oaupvbkywL i9wKKGaQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR1Ym-00000007QTC-0OSd; Tue, 09 Jul 2024 03:30:32 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 08/10] ufs: Convert ufs_prepare_chunk() to take a folio Date: Tue, 9 Jul 2024 04:30:25 +0100 Message-ID: <20240709033029.1769992-9-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709033029.1769992-1-willy@infradead.org> References: <20240709033029.1769992-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/ufs/dir.c | 8 ++++---- fs/ufs/inode.c | 4 ++-- fs/ufs/util.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 6a2a6af38097..a20f66351c66 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -97,7 +97,7 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, int err; folio_lock(folio); - err = ufs_prepare_chunk(&folio->page, pos, len); + err = ufs_prepare_chunk(folio, pos, len); BUG_ON(err); de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino); @@ -366,7 +366,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) got_it: pos = folio_pos(folio) + offset_in_folio(folio, de); - err = ufs_prepare_chunk(&folio->page, pos, rec_len); + err = ufs_prepare_chunk(folio, pos, rec_len); if (err) goto out_unlock; if (de->d_ino) { @@ -521,7 +521,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, from = offset_in_folio(folio, pde); pos = folio_pos(folio) + from; folio_lock(folio); - err = ufs_prepare_chunk(&folio->page, pos, to - from); + err = ufs_prepare_chunk(folio, pos, to - from); BUG_ON(err); if (pde) pde->d_reclen = cpu_to_fs16(sb, to - from); @@ -549,7 +549,7 @@ int ufs_make_empty(struct inode * inode, struct inode *dir) if (IS_ERR(folio)) return PTR_ERR(folio); - err = ufs_prepare_chunk(&folio->page, 0, chunk_size); + err = ufs_prepare_chunk(folio, 0, chunk_size); if (err) { folio_unlock(folio); goto fail; diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index a7bb2e63cdde..0e608fc0d0fd 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -479,9 +479,9 @@ static int ufs_read_folio(struct file *file, struct folio *folio) return block_read_full_folio(folio, ufs_getfrag_block); } -int ufs_prepare_chunk(struct page *page, loff_t pos, unsigned len) +int ufs_prepare_chunk(struct folio *folio, loff_t pos, unsigned len) { - return __block_write_begin(page, pos, len, ufs_getfrag_block); + return __block_write_begin(&folio->page, pos, len, ufs_getfrag_block); } static void ufs_truncate_blocks(struct inode *); diff --git a/fs/ufs/util.h b/fs/ufs/util.h index 0ecd2ed792f5..bf708b68f150 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h @@ -250,9 +250,9 @@ ufs_set_inode_gid(struct super_block *sb, struct ufs_inode *inode, u32 value) } } -extern dev_t ufs_get_inode_dev(struct super_block *, struct ufs_inode_info *); -extern void ufs_set_inode_dev(struct super_block *, struct ufs_inode_info *, dev_t); -extern int ufs_prepare_chunk(struct page *page, loff_t pos, unsigned len); +dev_t ufs_get_inode_dev(struct super_block *, struct ufs_inode_info *); +void ufs_set_inode_dev(struct super_block *, struct ufs_inode_info *, dev_t); +int ufs_prepare_chunk(struct folio *folio, loff_t pos, unsigned len); /* * These functions manipulate ufs buffers From patchwork Tue Jul 9 03:30:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13727236 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 D73AB42067 for ; Tue, 9 Jul 2024 03:30:33 +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=1720495836; cv=none; b=d9H3d15nKJmHHpwwYmMskxBj2RE2buz16EHPfx4+MnbXQQLKgKH2lWFWwlX20MI3NAFss1xp/AY/Uf9YgYm6R3iu6tUDX+fCc29CmX57EUuFd1WLQ8QrJL0PBSJ6REWHGrVJ4DlAK2QpdzCYLlEgEtyDGsjCMpGY3+km/v39RII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720495836; c=relaxed/simple; bh=YsBuYwNxyCtU1ndknAGW867NljFfrltww4qmsIB/LJ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cu7Xqn7phHlO0ru4RxQham7StHctyYgf/MF8FtfNDOWgUKZ0zFwHxsknJTp6fpv+qIkk6bBmRLq+PZImh1IXIIwOLm9nU4JF4/DjM4nI1ghGlhggc11T4vBdXYLG9yL0URZ5oGCPPh2qEkbc6iItVZ0XXwKNgflmmP0EKa4awFQ= 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=KB54zUT4; 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="KB54zUT4" 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=GQY9LoA8hNCAWXgQD5p24hGXMklnNxC7e+IGOlnepnU=; b=KB54zUT4pn/6itZOFfUbtNKg9n kAlauTauiRimnCzq4b0LhaDSs9bVnKuO2hkUZBrJtg3n3+bSQ6yHdvMGoqx+Sj45jbI4RkWP9RRVP DDji/smsFCMZq529lH/joHnZUttN8Eu/FwdeQwoESMkmu1yauAuf4dUoLcfWsIy+Mz8DnpG9q2Lmb gERpZws6eJAvZKeqew+fi6rDGPm7OX0SeQsPPt+fy3J+oxj+9sYA0J6tOZNaWcVvlM0QOy0lC3riq IhV9WUJ507uMy8cmLqjAgcD5HGXL4GRzjvuSzUgAhKCdud+4Q5RWbclk07zwpBscs+Msgjv65ub0e DAKz6pIA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR1Ym-00000007QTJ-0t0T; Tue, 09 Jul 2024 03:30:32 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 09/10] ufs; Convert ufs_commit_chunk() to take a folio Date: Tue, 9 Jul 2024 04:30:26 +0100 Message-ID: <20240709033029.1769992-10-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709033029.1769992-1-willy@infradead.org> References: <20240709033029.1769992-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/ufs/dir.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index a20f66351c66..71685491d5f6 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -42,18 +42,18 @@ static inline int ufs_match(struct super_block *sb, int len, return !memcmp(name, de->d_name, len); } -static void ufs_commit_chunk(struct page *page, loff_t pos, unsigned len) +static void ufs_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; inode_inc_iversion(dir); - 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 ufs_handle_dirsync(struct inode *dir) @@ -103,7 +103,7 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, 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->page, pos, len); + ufs_commit_chunk(folio, pos, len); ufs_put_page(&folio->page); if (update_times) inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); @@ -383,7 +383,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) de->d_ino = cpu_to_fs32(sb, inode->i_ino); ufs_set_de_type(sb, de, inode->i_mode); - ufs_commit_chunk(&folio->page, pos, rec_len); + ufs_commit_chunk(folio, pos, rec_len); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); mark_inode_dirty(dir); @@ -526,7 +526,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, if (pde) pde->d_reclen = cpu_to_fs16(sb, to - from); dir->d_ino = 0; - ufs_commit_chunk(&folio->page, pos, to - from); + 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); @@ -574,7 +574,7 @@ int ufs_make_empty(struct inode * inode, struct inode *dir) strcpy (de->d_name, ".."); kunmap_local(kaddr); - ufs_commit_chunk(&folio->page, 0, chunk_size); + ufs_commit_chunk(folio, 0, chunk_size); err = ufs_handle_dirsync(inode); fail: folio_put(folio); From patchwork Tue Jul 9 03:30:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13727233 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 722464502B for ; Tue, 9 Jul 2024 03:30:34 +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=1720495836; cv=none; b=IacpXGKOvzEZqvLCKxSMvVvuuPMcfBqlBgCjlwln/2+NNxQpF9iubuN+6bVD5snaB4tKp+zIyJ98O3HhIl0rsOQfqPRDHnFq/Riq1AyXg1ZBTfzTPbcFIDc//O3k0bS1kh75iU13E00gEauDFpgBej7+1i6m4nVIMmAfSDfkw9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720495836; c=relaxed/simple; bh=B93pKBCMwrta/cZfJ08CRHvHvzJunHpVHvZUnMVLT34=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DvlPnffBDV8bO28Td1eQnuWeKYgNbRUd9GkFGZspPff0jziZQBXe+pmXYtSEaslIn6IbwchYD6gSqrkA+Te2ZUyEUmcb3fRsEZeZ0HfhVM230A7/AUoMyZRDNsTrRBn/7rW+cMH5Wn79s0fyUeWZa7r/LNj4qjK3p+CsznMQ5kQ= 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=Gu1CHuK1; 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="Gu1CHuK1" 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=/Y+PqX7MwRu1AeQN2mFg5ga0TpDmNlJByyAfOKwi7ck=; b=Gu1CHuK1hgQ8CSMqGAF9t4SNCT UaRnR8GZvv+JUYRlyE2bdB63Ew/oayfJSqsEGygpfIwmvZOB2Wtyjtk0LUi8OQYWBhk4vkE1jA3ml I6qu7dIaNovia4ToqUSX2h91rH2ewwzHk656dDIqA+6M8U0KgXYRUBoPKOamNHx1Lr/Ljr3uA/zU4 sjl0I9vrrhd6lT0ZX7iD+kRM1zg7HRcMn72ZQGpmtQJY1SggNwWo81T2r2NbAYWKyDsZIzhQa5uq5 Xjp/onyUVDBi1RcELPxEuV9hnchskkzZbfssI+Vd6VvfJHyvCEPLwJbzRIjTV75lmvTtdk/UK/TN+ Oqyn/KGA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR1Ym-00000007QTQ-1S4t; Tue, 09 Jul 2024 03:30:32 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig Subject: [PATCH 10/10] ufs: Convert directory handling to kmap_local Date: Tue, 9 Jul 2024 04:30:27 +0100 Message-ID: <20240709033029.1769992-11-willy@infradead.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240709033029.1769992-1-willy@infradead.org> References: <20240709033029.1769992-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 kmap use and use folio_release_kmap() instead of ufs_put_page(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/ufs/dir.c | 30 ++++++++++++------------------ fs/ufs/namei.c | 15 +++++---------- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 71685491d5f6..3b3cd84f1f7f 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -66,12 +66,6 @@ static int ufs_handle_dirsync(struct inode *dir) return err; } -static inline void ufs_put_page(struct page *page) -{ - kunmap(page); - put_page(page); -} - ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr) { ino_t res = 0; @@ -81,7 +75,7 @@ ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr) de = ufs_find_entry(dir, qstr, &folio); if (de) { res = fs32_to_cpu(dir->i_sb, de->d_ino); - ufs_put_page(&folio->page); + folio_release_kmap(folio, de); } return res; } @@ -104,7 +98,7 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, ufs_set_de_type(dir->i_sb, de, inode->i_mode); ufs_commit_chunk(folio, pos, len); - ufs_put_page(&folio->page); + folio_release_kmap(folio, de); if (update_times) inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); mark_inode_dirty(dir); @@ -197,7 +191,7 @@ static void *ufs_get_folio(struct inode *dir, unsigned long n, if (IS_ERR(folio)) return ERR_CAST(folio); - kaddr = kmap(&folio->page); + kaddr = kmap_local_folio(folio, 0); if (unlikely(!folio_test_checked(folio))) { if (!ufs_check_folio(folio, kaddr)) goto fail; @@ -206,7 +200,7 @@ static void *ufs_get_folio(struct inode *dir, unsigned long n, return kaddr; fail: - ufs_put_page(&folio->page); + folio_release_kmap(folio, kaddr); return ERR_PTR(-EIO); } @@ -283,7 +277,7 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr, goto found; de = ufs_next_entry(sb, de); } - ufs_put_page(&(*foliop)->page); + folio_release_kmap(*foliop, kaddr); } if (++n >= npages) n = 0; @@ -359,7 +353,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) de = (struct ufs_dir_entry *) ((char *) de + rec_len); } folio_unlock(folio); - ufs_put_page(&folio->page); + folio_release_kmap(folio, kaddr); } BUG(); return -EINVAL; @@ -390,7 +384,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) err = ufs_handle_dirsync(dir); /* OFFSET_CACHE */ out_put: - ufs_put_page(&folio->page); + folio_release_kmap(folio, de); return err; out_unlock: folio_unlock(folio); @@ -468,13 +462,13 @@ ufs_readdir(struct file *file, struct dir_context *ctx) ufs_get_de_namlen(sb, de), fs32_to_cpu(sb, de->d_ino), d_type)) { - ufs_put_page(&folio->page); + folio_release_kmap(folio, de); return 0; } } ctx->pos += fs16_to_cpu(sb, de->d_reclen); } - ufs_put_page(&folio->page); + folio_release_kmap(folio, kaddr); } return 0; } @@ -531,7 +525,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, mark_inode_dirty(inode); err = ufs_handle_dirsync(inode); out: - ufs_put_page(&folio->page); + folio_release_kmap(folio, kaddr); UFSD("EXIT\n"); return err; } @@ -624,12 +618,12 @@ int ufs_empty_dir(struct inode * inode) } de = ufs_next_entry(sb, de); } - ufs_put_page(&folio->page); + folio_release_kmap(folio, kaddr); } return 1; not_empty: - ufs_put_page(&folio->page); + folio_release_kmap(folio, kaddr); return 0; } diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index a9b0c15de067..24bd12186647 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c @@ -306,23 +306,18 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir, if (dir_de) { if (old_dir != new_dir) ufs_set_link(old_inode, dir_de, dir_folio, new_dir, 0); - else { - kunmap(&dir_folio->page); - folio_put(dir_folio); - } + else + folio_release_kmap(dir_folio, new_dir); inode_dec_link_count(old_dir); } return 0; out_dir: - if (dir_de) { - kunmap(&dir_folio->page); - folio_put(dir_folio); - } + if (dir_de) + folio_release_kmap(dir_folio, dir_de); out_old: - kunmap(&old_folio->page); - folio_put(old_folio); + folio_release_kmap(old_folio, old_de); out: return err; }