From patchwork Thu Dec 5 17:16:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895851 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 52FD2224B01; Thu, 5 Dec 2024 17:17:16 +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=1733419037; cv=none; b=FP1pVdPi/KyEVfVKtsiF5vdesRGw65dxP/1YHv/uLfwLi1yPbieU67GO8JKKJr88m5x324Lfp2utqMuGRZpkLjRMYWwHcXqOqWVbvQx1hQHRNqYyK9ifQ0JxvLswtB45VQ1C2kG6dXGTLM3BeDOuWurSqenpJCmRivX+uiwkt20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419037; c=relaxed/simple; bh=XzqZe47Br96RJjSNvIIZDKG/U/HC3VdMf6AvgKiRS30=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=au1/Ckl2MoVlDrUJ5I3E+xG+CiTgPjBcbJ79s1Sl7jPZdL3wh54NuVE50Z2m7vOxy8Q7Th8STQyIaTd0s9cCRG69CHbAmuoFIKqfEt4xYBTGRwqjtiBjevGA+HawALj/ae1N2gC9d8YkG+Sj1LoGjoh1WDYnMS2zuPl+u6jP0d0= 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=FAPypP8P; 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="FAPypP8P" 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=uMpWjAoCXwStx8LVwMyFrNoBQli1b1MJmeVAnjw+Jis=; b=FAPypP8Ps5+Z7HoQBezVb4bLdq mNnGykT2LxliiHJds8o5m6kuejSXLv83YoExiqyhT4XEHbJ21o1TmgVMrRd6uw3dForpJyVsVlu6P CkAt8UQWn3XBAqhPUzvKg+3WVJSrJO/vADVfoG7CcAFlC6HySUMZjqN+M0N6aAExcyqW5GAbZksQU tFxT22CoGTZoP5vnQiNg7KUJi2JcU9lud0Ti5/FwM23sUQtwLy3ZG70HVKa/kSi96Od9RMH6hLJC0 gFVygV+zo39V5Q55Nztq0lqS7PdDt/c66ECDR2ga4PRGlZMwEKfSzx0m7m0cHKd2qMHeceRK+3JfZ endEMUmg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTF-0000000DLFm-2kV1; Thu, 05 Dec 2024 17:16:57 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: "Matthew Wilcox (Oracle)" , ocfs2-devel@lists.linux.dev, Mark Tinguely , stable@vger.kernel.org Subject: [PATCH 01/23] ocfs2: Handle a symlink read error correctly Date: Thu, 5 Dec 2024 17:16:29 +0000 Message-ID: <20241205171653.3179945-2-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If we can't read the buffer, be sure to unlock the page before returning. Signed-off-by: Matthew Wilcox (Oracle) Cc: stable@vger.kernel.org Reviewed-by: Joseph Qi --- fs/ocfs2/symlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index d4c5fdcfa1e4..f5cf2255dc09 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c @@ -65,7 +65,7 @@ static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio) if (status < 0) { mlog_errno(status); - return status; + goto out; } fe = (struct ocfs2_dinode *) bh->b_data; @@ -76,9 +76,10 @@ static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio) memcpy(kaddr, link, len + 1); kunmap_atomic(kaddr); SetPageUptodate(page); +out: unlock_page(page); brelse(bh); - return 0; + return status; } const struct address_space_operations ocfs2_fast_symlink_aops = { From patchwork Thu Dec 5 17:16:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895852 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 5DF66224B19 for ; Thu, 5 Dec 2024 17:17: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=1733419042; cv=none; b=eQwFeP8OIeqTH8EouwM4HnnpUR+6Iqt/xK+R6HL0icNJmN+7IOf0pfkqCeEd7+y8eru8i5GaM/RUg/uBVjQsZq8NcVqDbE/pio6Zrz6tdJpwglTFJgc7QTvYvkcA9J8yJ4+vZjsu9QukCmGYuEga0IuBh/pHRxpTv/DPIf6OqX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419042; c=relaxed/simple; bh=+pEHFCJRYVp9wtgA/S5vssAiOAjG8k4Bx/srLVrStww=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hDJENvK/6HAcf9GmygbQ3j7N17rLwrLksrxHg8u1Qo+bNY8xPt1wiDNtJSx93f44rElSMNRtI5YABY5o9UwqvOwX225Le7sJfZuhuqn8taPLpOM87VT6dRUqVjzjSrGw3x6hTPKf/PafVEYaGpyjweVhl5nbtfKKwQDp04LWJds= 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=GRccSQdO; 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="GRccSQdO" 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=Z/xqKKp3dYECHXezf7zpZ7Z3huCAA1R3z+3QlvEr5Tc=; b=GRccSQdOCFSr63KZrg0GM9oLYp zjVZnoZ7CEw8Ry7MojmiWArqfoW8xu+FgdEB847nR44MDchs34yTFlurdzyU0sy2xLDMtKbi1J/HS WWJb+fAwLIF+02q7fxL1gNH00/bq8iCVRyl3s97gkBUu7mb4e3jGzTSqJWVSDYyCLJzKkL6af7RXh 1Aob6bazhOrRR+CG3vHlHT/1Iu9nCO1TXqU5mnH5Tffxk5npjpKZYJ78ByPMo1my+b+WLNK0kZCxm t0d9dysaR7zr5dZVpNeSRy1I2hv7qutGM4gegURAGHYXEm43kwOXYMvVmYf/9dR2t7oRyhEXSPARo 9OoRslxA==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTF-0000000DLFo-3FlE; Thu, 05 Dec 2024 17:16:57 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: "Matthew Wilcox (Oracle)" , ocfs2-devel@lists.linux.dev, Mark Tinguely Subject: [PATCH 02/23] ocfs2: Convert ocfs2_page_mkwrite() to use a folio Date: Thu, 5 Dec 2024 17:16:30 +0000 Message-ID: <20241205171653.3179945-3-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Pass the folio into __ocfs2_page_mkwrite() and use it throughout. Does not attempt to support large folios. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/mmap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c index 6ef4cb045ccd..93b886f16c40 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c @@ -44,13 +44,13 @@ static vm_fault_t ocfs2_fault(struct vm_fault *vmf) } static vm_fault_t __ocfs2_page_mkwrite(struct file *file, - struct buffer_head *di_bh, struct page *page) + struct buffer_head *di_bh, struct folio *folio) { int err; vm_fault_t ret = VM_FAULT_NOPAGE; struct inode *inode = file_inode(file); struct address_space *mapping = inode->i_mapping; - loff_t pos = page_offset(page); + loff_t pos = folio_pos(folio); unsigned int len = PAGE_SIZE; pgoff_t last_index; struct folio *locked_folio = NULL; @@ -72,9 +72,9 @@ static vm_fault_t __ocfs2_page_mkwrite(struct file *file, * * Let VM retry with these cases. */ - if ((page->mapping != inode->i_mapping) || - (!PageUptodate(page)) || - (page_offset(page) >= size)) + if ((folio->mapping != inode->i_mapping) || + !folio_test_uptodate(folio) || + (pos >= size)) goto out; /* @@ -87,11 +87,11 @@ static vm_fault_t __ocfs2_page_mkwrite(struct file *file, * worry about ocfs2_write_begin() skipping some buffer reads * because the "write" would invalidate their data. */ - if (page->index == last_index) + if (folio->index == last_index) len = ((size - 1) & ~PAGE_MASK) + 1; err = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_MMAP, - &locked_folio, &fsdata, di_bh, page); + &locked_folio, &fsdata, di_bh, &folio->page); if (err) { if (err != -ENOSPC) mlog_errno(err); @@ -112,7 +112,7 @@ static vm_fault_t __ocfs2_page_mkwrite(struct file *file, static vm_fault_t ocfs2_page_mkwrite(struct vm_fault *vmf) { - struct page *page = vmf->page; + struct folio *folio = page_folio(vmf->page); struct inode *inode = file_inode(vmf->vma->vm_file); struct buffer_head *di_bh = NULL; sigset_t oldset; @@ -141,7 +141,7 @@ static vm_fault_t ocfs2_page_mkwrite(struct vm_fault *vmf) */ down_write(&OCFS2_I(inode)->ip_alloc_sem); - ret = __ocfs2_page_mkwrite(vmf->vma->vm_file, di_bh, page); + ret = __ocfs2_page_mkwrite(vmf->vma->vm_file, di_bh, folio); up_write(&OCFS2_I(inode)->ip_alloc_sem); From patchwork Thu Dec 5 17:16:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895858 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 1EF4F226EEF for ; Thu, 5 Dec 2024 17:17:31 +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=1733419052; cv=none; b=YhBcr1eaJchWByMu0SU2tdowcDgS2Zqgia1KiwUQnG4mY2SnXT0Sjq0/U1aaxuisl6i6MN6VGqlXQnkL2wImMZUea3HpbQzlZZ0N4zyOGa+ZgcHVj3vOWa30uIc+fN1naK9usYhYJk9wzXng64e/F0O1uFG2G0+sSpZI/L7bXMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419052; c=relaxed/simple; bh=8xeCXFK9ke36BvmkF3A55rGNSCrXBlAPeaXfPDdNDPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cF8Aj8gKd1moiHzduAH0GoQwEF1eMy2Gdo9Yjg4ai8uLxidz3+F4JaZqEGCKzqemRM45hlUezpkakjNgQbKmll+UjQiao2N/YTLK/Lv+cLRZ5vIXp7zdyKMbx1F7NxcTon6l0JCEQE5Pz+w9w3EXbY9EGPOcfU9ReP6n/OjCZhw= 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=d4Pd7YPT; 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="d4Pd7YPT" 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=cqsl7npi+nQUFIUhi0su7fzPscqJ/FxRPxJlndPcZiE=; b=d4Pd7YPTtJtByQhR2xoQaE/RAo HsIfIIyOJYfdzfWDeRv8rC2NnFHHkW4/nuLHYJXFoQroQEm8Dr6kG8oybu+qky7Q87kZdCJzZW0uD vxI9B5j7UHoKiu9FrZANStKNrO6Ov9eCfjHpRVSaVHFhnFZ0m7So9NPnjDE2YRjmjQvb4wrGeFJSf W9PXVqp1xL/kRxmN5gECwh2C4Qb7P1V9kN/eHBy+pMfYIJxtyvxAZt5hrot5htHmowgjbohhiN4Ry a6uPU26CNKYlO1Qzgr24kBFvILifRtAuzuryjqSQHz2UkMHy46ZhZwwbNHqJYP3NLHcueHE4XyX/c GlLCh4XQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTF-0000000DLFq-3dXB; Thu, 05 Dec 2024 17:16:57 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 03/23] ocfs2: Convert w_target_page to w_target_folio Date: Thu, 5 Dec 2024 17:16:31 +0000 Message-ID: <20241205171653.3179945-4-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Pass a folio around instead of a page. Saves a few hidden calls to compound_head() and removes a call to kmap_atomic(). Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 63 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index db72b3e924b3..5f7a33335385 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -731,22 +731,22 @@ struct ocfs2_write_ctxt { /* * Pages involved in this write. * - * w_target_page is the page being written to by the user. + * w_target_folio is the folio being written to by the user. * * w_pages is an array of pages which always contains - * w_target_page, and in the case of an allocating write with + * w_target_folio, and in the case of an allocating write with * page_size < cluster size, it will contain zero'd and mapped - * pages adjacent to w_target_page which need to be written + * pages adjacent to w_target_folio which need to be written * out in so that future reads from that region will get * zero's. */ unsigned int w_num_pages; struct page *w_pages[OCFS2_MAX_CTXT_PAGES]; - struct page *w_target_page; + struct folio *w_target_folio; /* * w_target_locked is used for page_mkwrite path indicating no unlocking - * against w_target_page in ocfs2_write_end_nolock. + * against w_target_folio in ocfs2_write_end_nolock. */ unsigned int w_target_locked:1; @@ -791,18 +791,18 @@ static void ocfs2_unlock_pages(struct ocfs2_write_ctxt *wc) /* * w_target_locked is only set to true in the page_mkwrite() case. * The intent is to allow us to lock the target page from write_begin() - * to write_end(). The caller must hold a ref on w_target_page. + * to write_end(). The caller must hold a ref on w_target_folio. */ if (wc->w_target_locked) { - BUG_ON(!wc->w_target_page); + BUG_ON(!wc->w_target_folio); for (i = 0; i < wc->w_num_pages; i++) { - if (wc->w_target_page == wc->w_pages[i]) { + if (&wc->w_target_folio->page == wc->w_pages[i]) { wc->w_pages[i] = NULL; break; } } - mark_page_accessed(wc->w_target_page); - put_page(wc->w_target_page); + folio_mark_accessed(wc->w_target_folio); + folio_put(wc->w_target_folio); } ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages); } @@ -869,8 +869,9 @@ static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt **wcp, * and dirty so they'll be written out (in order to prevent uninitialised * block data from leaking). And clear the new bit. */ -static void ocfs2_zero_new_buffers(struct page *page, unsigned from, unsigned to) +static void ocfs2_zero_new_buffers(struct folio *folio, unsigned from, unsigned to) { + struct page *page = &folio->page; unsigned int block_start, block_end; struct buffer_head *head, *bh; @@ -918,8 +919,8 @@ static void ocfs2_write_failure(struct inode *inode, to = user_pos + user_len; struct page *tmppage; - if (wc->w_target_page) - ocfs2_zero_new_buffers(wc->w_target_page, from, to); + if (wc->w_target_folio) + ocfs2_zero_new_buffers(wc->w_target_folio, from, to); for(i = 0; i < wc->w_num_pages; i++) { tmppage = wc->w_pages[i]; @@ -954,7 +955,7 @@ static int ocfs2_prepare_page_for_write(struct inode *inode, u64 *p_blkno, new = new | ((i_size_read(inode) <= page_offset(page)) && (page_offset(page) <= user_pos)); - if (page == wc->w_target_page) { + if (page == &wc->w_target_folio->page) { map_from = user_pos & (PAGE_SIZE - 1); map_to = map_from + user_len; @@ -1097,7 +1098,7 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping, wait_for_stable_page(wc->w_pages[i]); if (index == target_index) - wc->w_target_page = wc->w_pages[i]; + wc->w_target_folio = page_folio(wc->w_pages[i]); } out: if (ret) @@ -1494,7 +1495,8 @@ static int ocfs2_write_begin_inline(struct address_space *mapping, * If we don't set w_num_pages then this page won't get unlocked * and freed on cleanup of the write context. */ - wc->w_pages[0] = wc->w_target_page = page; + wc->w_target_folio = page_folio(page); + wc->w_pages[0] = page; wc->w_num_pages = 1; ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, @@ -1803,7 +1805,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, * the operation. */ if (type == OCFS2_WRITE_MMAP && ret == -EAGAIN) { - BUG_ON(wc->w_target_page); + BUG_ON(wc->w_target_folio); ret = 0; goto out_quota; } @@ -1826,7 +1828,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, success: if (foliop) - *foliop = page_folio(wc->w_target_page); + *foliop = wc->w_target_folio; *fsdata = wc; return 0; out_quota: @@ -1924,18 +1926,15 @@ static void ocfs2_write_end_inline(struct inode *inode, loff_t pos, struct ocfs2_dinode *di, struct ocfs2_write_ctxt *wc) { - void *kaddr; - if (unlikely(*copied < len)) { - if (!PageUptodate(wc->w_target_page)) { + if (!folio_test_uptodate(wc->w_target_folio)) { *copied = 0; return; } } - kaddr = kmap_atomic(wc->w_target_page); - memcpy(di->id2.i_data.id_data + pos, kaddr + pos, *copied); - kunmap_atomic(kaddr); + memcpy_from_folio(di->id2.i_data.id_data + pos, wc->w_target_folio, + pos, *copied); trace_ocfs2_write_end_inline( (unsigned long long)OCFS2_I(inode)->ip_blkno, @@ -1973,15 +1972,15 @@ int ocfs2_write_end_nolock(struct address_space *mapping, goto out_write_size; } - if (unlikely(copied < len) && wc->w_target_page) { + if (unlikely(copied < len) && wc->w_target_folio) { loff_t new_isize; - if (!PageUptodate(wc->w_target_page)) + if (!folio_test_uptodate(wc->w_target_folio)) copied = 0; new_isize = max_t(loff_t, i_size_read(inode), pos + copied); - if (new_isize > page_offset(wc->w_target_page)) - ocfs2_zero_new_buffers(wc->w_target_page, start+copied, + if (new_isize > folio_pos(wc->w_target_folio)) + ocfs2_zero_new_buffers(wc->w_target_folio, start+copied, start+len); else { /* @@ -1991,12 +1990,12 @@ int ocfs2_write_end_nolock(struct address_space *mapping, * put page & buffer dirty bits into inconsistent * state. */ - block_invalidate_folio(page_folio(wc->w_target_page), + block_invalidate_folio(wc->w_target_folio, 0, PAGE_SIZE); } } - if (wc->w_target_page) - flush_dcache_page(wc->w_target_page); + if (wc->w_target_folio) + flush_dcache_folio(wc->w_target_folio); for(i = 0; i < wc->w_num_pages; i++) { tmppage = wc->w_pages[i]; @@ -2005,7 +2004,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping, if (tmppage == NULL) continue; - if (tmppage == wc->w_target_page) { + if (tmppage == &wc->w_target_folio->page) { from = wc->w_target_from; to = wc->w_target_to; From patchwork Thu Dec 5 17:16:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895841 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 A329922579D for ; Thu, 5 Dec 2024 17:17:04 +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=1733419026; cv=none; b=io5NyNoQrSiAhOGsfeEeOgsWscAZHHB0gWsA6BuMtM2Dvhvv/XiDfXsyE+0IEp4Gl6D0kgSuRR4IWXu+b/RXSbmWf6vwlBuzWOP0uuR2mq1RykG2uCz7C2HWMPM8wbBABW7FQYwFtqFOyRBuZFOem//VNC674iFF+klf7pPOyzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419026; c=relaxed/simple; bh=vIU8SOwv+D850DeH5NGDvqee10MXn1jBfQenmaOAJY8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oiDf6GtVdMi3eT4Ja/D0wyM9n1dInsZ74Yy0Ezirlag5ud4tO6DsEuWB49iJMO6PiY3I5xSsvF//tmGlWJ7CIanj4H7ewsgtOLopR9sz54hVn+Kh7TLpuO1CK7nBwQOuMRzG7WNCWTTX+b+b1hKTiA7sz6MZThwMrTL/rDk/HiI= 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=VFrfG9Qh; 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="VFrfG9Qh" 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=r96vd6xrwukyFRDIBh14pXq1M2Bi+IpWAVGrU2Z4o9o=; b=VFrfG9QhqYp/C96Voz2kPpQI3G 42Z7YUlMsXoA2QrB/0nfB3UgLERK188EEbf2Sb1jeRNY7vEG7yc1ilhSFxO0b/sOMe//l0fY2hlqy Vz7lYIDw78zF52XNLNNZl1ndoxZr8dRtu/i94hXtFi8D2st8WamxordiACBuC0qVU5Y5dWBJCvidR vigUBWMvYheBjxvh50hZQgZ35PvY7/rMv7++O2utABzEqtKGGVZhJH61UFw3VV3YMez4bBqYqHOmf YCiAZ19KdabPL0otqMlhCk3EHxdG7gLnZxU6/m3or1tJp7XUHNSwuGmnsDzZ65VsGl5VGVLV92bUT dPp3QoJw==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTF-0000000DLFv-3xat; Thu, 05 Dec 2024 17:16:57 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 04/23] ocfs2: Use a folio in ocfs2_zero_new_buffers() Date: Thu, 5 Dec 2024 17:16:32 +0000 Message-ID: <20241205171653.3179945-5-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Convert to the new APIs, saving at least one hidden call to compound_head(). Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 5f7a33335385..a1fad246765a 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -869,30 +869,30 @@ static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt **wcp, * and dirty so they'll be written out (in order to prevent uninitialised * block data from leaking). And clear the new bit. */ -static void ocfs2_zero_new_buffers(struct folio *folio, unsigned from, unsigned to) +static void ocfs2_zero_new_buffers(struct folio *folio, size_t from, size_t to) { - struct page *page = &folio->page; unsigned int block_start, block_end; struct buffer_head *head, *bh; - BUG_ON(!PageLocked(page)); - if (!page_has_buffers(page)) + BUG_ON(!folio_test_locked(folio)); + head = folio_buffers(folio); + if (!head) return; - bh = head = page_buffers(page); + bh = head; block_start = 0; do { block_end = block_start + bh->b_size; if (buffer_new(bh)) { if (block_end > from && block_start < to) { - if (!PageUptodate(page)) { + if (!folio_test_uptodate(folio)) { unsigned start, end; start = max(from, block_start); end = min(to, block_end); - zero_user_segment(page, start, end); + folio_zero_segment(folio, start, end); set_buffer_uptodate(bh); } From patchwork Thu Dec 5 17:16:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895854 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 65A20224AFB for ; Thu, 5 Dec 2024 17:17:25 +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=1733419046; cv=none; b=k+0yQCcGKEOO7cRM1r4QhXgLBjuJtJj5L8vxBOsCF8MlLVDLweRXmz9EjzMyij3/Pt8cNXZ9trRlCO1IAIdMWiIokfFa9vW8DwA8L9sOsEICjIjFx9eFiy5GaZzAjjrSiLqNW2wXHNV7lEYo2FrsSA5eiysYPsK67+G6eIlP3kM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419046; c=relaxed/simple; bh=tswV19BVMIyYZNvmb+Y+lCWAP2p2euXsalogCtQprKU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AuoRVNc6q0fkuzHLAcvh+pVW1T9kevLLUoV5QrUMzoe5WejeuNn+JWGeP5cY3HTNrq+ggsOABzXC9J2ai5RxYwaw/2jrdlv+2sbae6yP+WXEtij7NKw1O4h1Ll3hRD50iQO2HkdHK6FgFgPK50KnTJg6SYjSCnW6fjJLi5Mb+AM= 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=SUIBUvQf; 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="SUIBUvQf" 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=vTTd32Vu3Z1fLZgXuc24Lick32tqUIHO5MQvNSIx5Cc=; b=SUIBUvQfNcSS1kiDMD1IpdlKtc SLmCioFg3cZ/nOBborKuY4D51nspR1FM7/BILAn+EYlwHQP8tLC4pkqEmD2OO96aulmVjbiyMdBCD FTg6TxhlwS3vZAr2uEwjzoSC/UYHjCjKQZA3nlfSE7spbRcEDH+aYUQe/lTW/U9SPZKESlHJkcwAp bKuQWGd0r2hkuofc5YujrNc6GX0bRFwBZVabDYK3vNGP7OgYv6Q/z0lfzYn3z2BJc+FjcCyPJ4nGJ jBWylcllUP8EXqwWNcD1wh6gwRr6dRVtHIEAJwO/BP0D2hGhYCJ3XpPDH6uqblZPut9e8taiwnuxr QE4lpNJw==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLFx-06oy; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 05/23] ocfs2: Use a folio in ocfs2_write_begin_inline() Date: Thu, 5 Dec 2024 17:16:33 +0000 Message-ID: <20241205171653.3179945-6-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Retrieve a folio from the page cache instead of a page and use that folio throught the function. Saves a couple of calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index a1fad246765a..c5e9c3462b84 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -1473,7 +1473,7 @@ static int ocfs2_write_begin_inline(struct address_space *mapping, { int ret; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); - struct page *page; + struct folio *folio; handle_t *handle; struct ocfs2_dinode *di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; @@ -1484,19 +1484,20 @@ static int ocfs2_write_begin_inline(struct address_space *mapping, goto out; } - page = find_or_create_page(mapping, 0, GFP_NOFS); - if (!page) { + folio = __filemap_get_folio(mapping, 0, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, GFP_NOFS); + if (IS_ERR(folio)) { ocfs2_commit_trans(osb, handle); - ret = -ENOMEM; + ret = PTR_ERR(folio); mlog_errno(ret); goto out; } /* - * If we don't set w_num_pages then this page won't get unlocked + * If we don't set w_num_pages then this folio won't get unlocked * and freed on cleanup of the write context. */ - wc->w_target_folio = page_folio(page); - wc->w_pages[0] = page; + wc->w_target_folio = folio; + wc->w_pages[0] = &folio->page; wc->w_num_pages = 1; ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, @@ -1511,8 +1512,8 @@ static int ocfs2_write_begin_inline(struct address_space *mapping, if (!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)) ocfs2_set_inode_data_inline(inode, di); - if (!PageUptodate(page)) { - ret = ocfs2_read_inline_data(inode, page, wc->w_di_bh); + if (!folio_test_uptodate(folio)) { + ret = ocfs2_read_inline_data(inode, &folio->page, wc->w_di_bh); if (ret) { ocfs2_commit_trans(osb, handle); From patchwork Thu Dec 5 17:16:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895861 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 603A1226EF3 for ; Thu, 5 Dec 2024 17:17:31 +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=1733419053; cv=none; b=ElJeXgfYLDI+d16K2NtwapE+XGU0i8ekFR3QMx0RdnpRWgJO80P3672rV/HZr/iVuWfGbOvYcmeYHe1bhU13qBmoLdE0HmMaGW2uVtfUP9MwN9eCs5iKTogEcITHPtgh51tNm8v2VDlXqD/Iyo1WM4IKhCzjv1V3WPmCCNthqRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419053; c=relaxed/simple; bh=6gJwNN85u+Uc2sqOfJPWF/35FiDjJm+yWGhdSV9O67s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f7eYErJ1bLr6qrNOz3NsjxnRmCciLMD3+5EVtw45hVVGT2G3fdpcpCfFChaiP/mMb9GXwY+Ljew4M2EQZgbucaRIiDnRUVyj1l9K+jbeo8h5p2q4Bz0imBaOL2aQOi4uxIbIzXXbk/DozXl9kPosxYHgx8ZYxK4zFjj9rtllitI= 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=Gqj2rWhk; 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="Gqj2rWhk" 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=Rm0ZzPISzXdjYe07sannLWkZ5pHNky3BouRz2PDCbQA=; b=Gqj2rWhk22xH9HNV+Efk47X/If IEjo/ttX9QCxQ99zhf43NwN7Ic4ncTRrVpS9xnQVFKZyrc5foIcExUNrD+skjjRr8OoZGrAszXN1L sPgOj3RdHxvKWZcrfgB+qGd32B+IKPZSzKY1Uygaf2nC3rfrbStZUPRMp5K/5u+sCWvppDVkFEwcH IptwAGlDeNJdqHN9XCyxH3WjhjO/DevGcwMzCPrzCx7sZF3+NNOSEhvBEsGP+oI8iXIRFC7KNXm9w EtRy5a9O4qtL6z/TCEN+geoMBgldY0dT7PIWch8Je/cfdJBms5gvPnelIijGLGjtxMRJn5R4m5Mqe FTBRcZwQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLFz-0Qwi; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: "Matthew Wilcox (Oracle)" , ocfs2-devel@lists.linux.dev, Mark Tinguely Subject: [PATCH 06/23] ocfs2: Pass mmap_folio around instead of mmap_page Date: Thu, 5 Dec 2024 17:16:34 +0000 Message-ID: <20241205171653.3179945-7-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Saves a few hidden calls to compound_head() and accesses to page->mapping. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 37 ++++++++++++++++++------------------- fs/ocfs2/aops.h | 6 +++--- fs/ocfs2/mmap.c | 2 +- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index c5e9c3462b84..aac644a0d25d 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -1023,7 +1023,7 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping, struct ocfs2_write_ctxt *wc, u32 cpos, loff_t user_pos, unsigned user_len, int new, - struct page *mmap_page) + struct folio *mmap_folio) { int ret = 0, i; unsigned long start, target_index, end_index, index; @@ -1068,18 +1068,18 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping, * and wants us to directly use the page * passed in. */ - lock_page(mmap_page); + folio_lock(mmap_folio); /* Exit and let the caller retry */ - if (mmap_page->mapping != mapping) { - WARN_ON(mmap_page->mapping); - unlock_page(mmap_page); + if (mmap_folio->mapping != mapping) { + WARN_ON(mmap_folio->mapping); + folio_unlock(mmap_folio); ret = -EAGAIN; goto out; } - get_page(mmap_page); - wc->w_pages[i] = mmap_page; + folio_get(mmap_folio); + wc->w_pages[i] = &mmap_folio->page; wc->w_target_locked = true; } else if (index >= target_index && index <= end_index && wc->w_type == OCFS2_WRITE_DIRECT) { @@ -1536,9 +1536,8 @@ int ocfs2_size_fits_inline_data(struct buffer_head *di_bh, u64 new_size) } static int ocfs2_try_to_write_inline_data(struct address_space *mapping, - struct inode *inode, loff_t pos, - unsigned len, struct page *mmap_page, - struct ocfs2_write_ctxt *wc) + struct inode *inode, loff_t pos, size_t len, + struct folio *mmap_folio, struct ocfs2_write_ctxt *wc) { int ret, written = 0; loff_t end = pos + len; @@ -1553,7 +1552,7 @@ static int ocfs2_try_to_write_inline_data(struct address_space *mapping, * Handle inodes which already have inline data 1st. */ if (oi->ip_dyn_features & OCFS2_INLINE_DATA_FL) { - if (mmap_page == NULL && + if (mmap_folio == NULL && ocfs2_size_fits_inline_data(wc->w_di_bh, end)) goto do_inline_write; @@ -1577,7 +1576,7 @@ static int ocfs2_try_to_write_inline_data(struct address_space *mapping, * Check whether the write can fit. */ di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; - if (mmap_page || + if (mmap_folio || end > ocfs2_max_inline_data_with_xattr(inode->i_sb, di)) return 0; @@ -1644,9 +1643,9 @@ static int ocfs2_zero_tail(struct inode *inode, struct buffer_head *di_bh, } int ocfs2_write_begin_nolock(struct address_space *mapping, - loff_t pos, unsigned len, ocfs2_write_type_t type, - struct folio **foliop, void **fsdata, - struct buffer_head *di_bh, struct page *mmap_page) + loff_t pos, unsigned len, ocfs2_write_type_t type, + struct folio **foliop, void **fsdata, + struct buffer_head *di_bh, struct folio *mmap_folio) { int ret, cluster_of_pages, credits = OCFS2_INODE_UPDATE_CREDITS; unsigned int clusters_to_alloc, extents_to_split, clusters_need = 0; @@ -1669,7 +1668,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, if (ocfs2_supports_inline_data(osb)) { ret = ocfs2_try_to_write_inline_data(mapping, inode, pos, len, - mmap_page, wc); + mmap_folio, wc); if (ret == 1) { ret = 0; goto success; @@ -1721,7 +1720,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, (unsigned long long)OCFS2_I(inode)->ip_blkno, (long long)i_size_read(inode), le32_to_cpu(di->i_clusters), - pos, len, type, mmap_page, + pos, len, type, mmap_folio, clusters_to_alloc, extents_to_split); /* @@ -1797,7 +1796,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, * extent. */ ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, len, - cluster_of_pages, mmap_page); + cluster_of_pages, mmap_folio); if (ret) { /* * ocfs2_grab_pages_for_write() returns -EAGAIN if it could not lock @@ -1848,7 +1847,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, * to VM code. */ if (wc->w_target_locked) - unlock_page(mmap_page); + folio_unlock(mmap_folio); ocfs2_free_write_ctxt(inode, wc); diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h index 1d1b4b7edba0..1cb46072ad84 100644 --- a/fs/ocfs2/aops.h +++ b/fs/ocfs2/aops.h @@ -37,9 +37,9 @@ typedef enum { } ocfs2_write_type_t; int ocfs2_write_begin_nolock(struct address_space *mapping, - loff_t pos, unsigned len, ocfs2_write_type_t type, - struct folio **foliop, void **fsdata, - struct buffer_head *di_bh, struct page *mmap_page); + loff_t pos, unsigned len, ocfs2_write_type_t type, + struct folio **foliop, void **fsdata, + struct buffer_head *di_bh, struct folio *mmap_folio); int ocfs2_read_inline_data(struct inode *inode, struct page *page, struct buffer_head *di_bh); diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c index 93b886f16c40..6a314e9f2b49 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c @@ -91,7 +91,7 @@ static vm_fault_t __ocfs2_page_mkwrite(struct file *file, len = ((size - 1) & ~PAGE_MASK) + 1; err = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_MMAP, - &locked_folio, &fsdata, di_bh, &folio->page); + &locked_folio, &fsdata, di_bh, folio); if (err) { if (err != -ENOSPC) mlog_errno(err); From patchwork Thu Dec 5 17:16:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895849 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 26A46226ED3 for ; Thu, 5 Dec 2024 17:17:10 +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=1733419031; cv=none; b=orPG0Ct37naDH+wewL7L4qqG5GDoNFTv7NY4nG6cx4kedxQU27Y0pAAYMEjht40TcJb243n7LQshqAVg7ROeWsE3omHl4bUpsSVTYH5BQTioFgkj7EWv3sU0WJekEP8ahqXavNVrU5vCnRIJMN4eI4lzOE3gBSZ7Z8rKO0YPD2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419031; c=relaxed/simple; bh=bPhplidBwP866DB1BHiMFKxsD6egrujx2QzIL0v5txw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m7wFCUB28jXjIZxDfTqwOgXHVvem1GQ33GFCwn7SAI/VMm0meKpbIuSEKNTVD9l9H7ltMdAfqYQ8mFLV2uX+eyR8n/TtXya/f+YKFdVShkViSeSWf3rCSjaF/GfhO/kD4YvxzycW4LHHq7XYSJWS1CVWtgS8emh3+jMXTRx3fdU= 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=WZXMqiHR; 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="WZXMqiHR" 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=ZnDPC/cUztlHqoXv6mY9VL4Zs18mgm4ZZNHtdRsRqYk=; b=WZXMqiHRKtMMf6Vt0aYcwduXxR Wm6npG6W+vxDVcnwwl9HQL6T4PjNRmWsqXPaxadPkzLmtfSkiuFOHYCnrhRJFKXSXdJmJl2P5KqMh bjoftFOMQ4zN5Y5Al3RgrF2KLDwsXyt9sxO9ox9oGm8zF3DoEhmG3g40mTAe8IZMZzABy5e5qZfLo 3nCFEnqoeS0HbXPW9IpTpk2cnNI4rDlPdvXuTlPvMrOh78DN2RTYqEVPb5B4rvZz65JsX6ZWz8ZCM nYpoA6wWcRgJEjQNisyj7QltDT/zjgU1WDTyg6GlSwW/YFG2auHLHBVS1tn+5a7AuB/+PVy+1At46 yHuUztTg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLG1-0oid; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 07/23] ocfs2: Convert ocfs2_readpage_inline() to take a folio Date: Thu, 5 Dec 2024 17:16:35 +0000 Message-ID: <20241205171653.3179945-8-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Save a couple of calls to compound_head() by using a folio throughout this function. Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index aac644a0d25d..1896a1d24173 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -252,12 +252,12 @@ int ocfs2_read_inline_data(struct inode *inode, struct page *page, return 0; } -static int ocfs2_readpage_inline(struct inode *inode, struct page *page) +static int ocfs2_readpage_inline(struct inode *inode, struct folio *folio) { int ret; struct buffer_head *di_bh = NULL; - BUG_ON(!PageLocked(page)); + BUG_ON(!folio_test_locked(folio)); BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)); ret = ocfs2_read_inode_block(inode, &di_bh); @@ -266,9 +266,9 @@ static int ocfs2_readpage_inline(struct inode *inode, struct page *page) goto out; } - ret = ocfs2_read_inline_data(inode, page, di_bh); + ret = ocfs2_read_inline_data(inode, &folio->page, di_bh); out: - unlock_page(page); + folio_unlock(folio); brelse(di_bh); return ret; @@ -322,7 +322,7 @@ static int ocfs2_read_folio(struct file *file, struct folio *folio) } if (oi->ip_dyn_features & OCFS2_INLINE_DATA_FL) - ret = ocfs2_readpage_inline(inode, &folio->page); + ret = ocfs2_readpage_inline(inode, folio); else ret = block_read_full_folio(folio, ocfs2_get_block); unlock = 0; From patchwork Thu Dec 5 17:16:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895857 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 1D3A4225771 for ; Thu, 5 Dec 2024 17:17:31 +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=1733419052; cv=none; b=eWrZ+uYPCVXWj0/CZbIQu3dQJ/2kzZxHulDZ16VZvVib1hrbjk/Nz3NBuhvTgQFtj60xugIoRpP6+pJQ946sbMCx0VbVqc04nrN68KYcM2axbIXyfP7mQva3ktpN4vRnvVKDf8eZ6oZftH6M822WZ/znkt/HbfZkyr4c54qco1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419052; c=relaxed/simple; bh=6fR8f8+LGeDTaaQVeUbng9ZDbQRCBSI7JuuVlSd5RQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nks02ftSDmewektoIPvrJbe0WcQ4b+Dm4VQ7yIiYE6uA4RRrTJYjHXvfm8EDK3bxX/oz9bNPf0QmAys5zPn9hH9vEvsQpZHHDscFeLEStEhg4NkpdJO51LQN2x4uKSJdmJsvVghbieliE08wjXmBJQDZgulbX2IZG3Yc/Aebx8U= 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=pbe1xFZt; 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="pbe1xFZt" 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=fdg2uRUNQgIAA/fpwgKroqdo3N6ku16P/WgOrL/JiCw=; b=pbe1xFZtdnM16W5D5vC4uefLmc sZONyQi6g3oobbwUk60OkKKngoc82Dsx8wyXwsOY+R+7/3x4+WomCrZ3bcmfk5iXPGE2Qd+oqAkLv Tk+ff9kordJdxS5TUeYPZbKTWwdweXEDuu994oeyo58GqKpq9YkqReBvUJoHB5kmHJk0vG57wmC+N DbGnA8/R4wxoUvpQRddGakUMf7aelGMjF5pyJJ+t9Ukkv7Zte2JYt87zclg3Wug4wIPQ14VwZyqEF 2ATE64IgI6Y6Wott6sMnyxBf1Sw/ibCfR8M0S5RGAM+k3HAjps+GOCSF+/Y1oxTtjG/9bv2oOFEPB E8aucP2Q==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLG4-1Fqa; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 08/23] ocfs2: Convert ocfs2_inode_lock_with_page() to ocfs2_inode_lock_with_folio() Date: Thu, 5 Dec 2024 17:16:36 +0000 Message-ID: <20241205171653.3179945-9-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Saves a hidden call to compound_head(). Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 2 +- fs/ocfs2/dlmglue.c | 18 ++++++++---------- fs/ocfs2/dlmglue.h | 6 ++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 1896a1d24173..161f2dc00b00 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -283,7 +283,7 @@ static int ocfs2_read_folio(struct file *file, struct folio *folio) trace_ocfs2_readpage((unsigned long long)oi->ip_blkno, folio->index); - ret = ocfs2_inode_lock_with_page(inode, NULL, 0, &folio->page); + ret = ocfs2_inode_lock_with_folio(inode, NULL, 0, folio); if (ret != 0) { if (ret == AOP_TRUNCATED_PAGE) unlock = 0; diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 60df52e4c1f8..acebfa19ea6f 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -2529,30 +2529,28 @@ int ocfs2_inode_lock_full_nested(struct inode *inode, /* * This is working around a lock inversion between tasks acquiring DLM - * locks while holding a page lock and the downconvert thread which - * blocks dlm lock acquiry while acquiring page locks. + * locks while holding a folio lock and the downconvert thread which + * blocks dlm lock acquiry while acquiring folio locks. * - * ** These _with_page variantes are only intended to be called from aop - * methods that hold page locks and return a very specific *positive* error + * ** These _with_folio variantes are only intended to be called from aop + * methods that hold folio locks and return a very specific *positive* error * code that aop methods pass up to the VFS -- test for errors with != 0. ** * * The DLM is called such that it returns -EAGAIN if it would have * blocked waiting for the downconvert thread. In that case we unlock - * our page so the downconvert thread can make progress. Once we've + * our folio so the downconvert thread can make progress. Once we've * done this we have to return AOP_TRUNCATED_PAGE so the aop method * that called us can bubble that back up into the VFS who will then * immediately retry the aop call. */ -int ocfs2_inode_lock_with_page(struct inode *inode, - struct buffer_head **ret_bh, - int ex, - struct page *page) +int ocfs2_inode_lock_with_folio(struct inode *inode, + struct buffer_head **ret_bh, int ex, struct folio *folio) { int ret; ret = ocfs2_inode_lock_full(inode, ret_bh, ex, OCFS2_LOCK_NONBLOCK); if (ret == -EAGAIN) { - unlock_page(page); + folio_unlock(folio); /* * If we can't get inode lock immediately, we should not return * directly here, since this will lead to a softlockup problem. diff --git a/fs/ocfs2/dlmglue.h b/fs/ocfs2/dlmglue.h index e5da5809ed95..a3ebd7303ea2 100644 --- a/fs/ocfs2/dlmglue.h +++ b/fs/ocfs2/dlmglue.h @@ -137,10 +137,8 @@ int ocfs2_inode_lock_full_nested(struct inode *inode, int ex, int arg_flags, int subclass); -int ocfs2_inode_lock_with_page(struct inode *inode, - struct buffer_head **ret_bh, - int ex, - struct page *page); +int ocfs2_inode_lock_with_folio(struct inode *inode, + struct buffer_head **ret_bh, int ex, struct folio *folio); /* Variants without special locking class or flags */ #define ocfs2_inode_lock_full(i, r, e, f)\ ocfs2_inode_lock_full_nested(i, r, e, f, OI_LS_NORMAL) From patchwork Thu Dec 5 17:16:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895853 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 5A5CB224AF7 for ; Thu, 5 Dec 2024 17:17:22 +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=1733419044; cv=none; b=Nk9+R5K4n31wRruM6Wt0IOZlNbtiobA3h/SdMLlWuJ9yh4pIJI3Cxewhl1fsPJF4LHBS68vswnapVUkjA5qAxUnJB3LLOSjHw7Fn+vRG8ytwtxyphxIPvJd3CDgDAJz9sewPuQdZ6XxiGKFekCE94ytHoZpQtMLqyB9f5M9HV3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419044; c=relaxed/simple; bh=WBaz6KPdmpk2jjKRn7lLXx2TvE7biahP7cOfgtphZ0g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H60xAvYFM1qMpyb9WlCUkwk9EU980hTbtX8hk2TYtlXbdP3pOUnZSgC1RLehD+nCpJzm7MEdHensyH0S5Gjcwkjz8jrJot+FEPhepVAVTlD7BGXTXCvPiIdQ3iPLL9ggsTAxc/9p8mr78wB2hKEgb2KEhQTX7+QCXN4PhlkffKo= 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=rmbSQGYk; 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="rmbSQGYk" 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=oF4SLrOsfX9v0GcUfxvLHj47dbwxFPNZfM1Y/e8rJnA=; b=rmbSQGYkt4+Kf+yqUsdPDbrRyU pXj3gLtxI6F4DB7cfEah0zMPd86BAbk7xjha22xIQwkkjXPlxfk1qKLen/w1STCatnSJ9B6sp+gnA mzlLL6P/HOwHc+aFG99RuDq5UcMyfMdjL5i5OUZ1XoiTtLcOOLMuUzALLIKePIAfWBcyeQyjDUrGb 4OPFZAZMNv9JAwcky8DJy7XhBX/ei38o99E6F2zHZIDx/89du0fXusLz1LyHiqNh0enmRGvt0hW9S GP3xdZP7R12an7UPozIz8eXF4hjvbiNxH03PExKONdfEMBrRykAqDjgwmbfJRvxZx7fXfbZ+hzgYH Uj13TODQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLG6-1h56; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 09/23] ocfs2: Convert w_pages to w_folios Date: Thu, 5 Dec 2024 17:16:37 +0000 Message-ID: <20241205171653.3179945-10-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Pass around an array of folios instead of an array of pages. Removes a few calls to compound_head(). Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 118 ++++++++++++++++++++++++++---------------------- fs/ocfs2/aops.h | 1 + 2 files changed, 65 insertions(+), 54 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 161f2dc00b00..afc20ab52b3e 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -729,19 +729,19 @@ struct ocfs2_write_ctxt { unsigned int w_large_pages; /* - * Pages involved in this write. + * Folios involved in this write. * * w_target_folio is the folio being written to by the user. * - * w_pages is an array of pages which always contains + * w_folios is an array of folios which always contains * w_target_folio, and in the case of an allocating write with * page_size < cluster size, it will contain zero'd and mapped * pages adjacent to w_target_folio which need to be written * out in so that future reads from that region will get * zero's. */ - unsigned int w_num_pages; - struct page *w_pages[OCFS2_MAX_CTXT_PAGES]; + unsigned int w_num_folios; + struct folio *w_folios[OCFS2_MAX_CTXT_PAGES]; struct folio *w_target_folio; /* @@ -771,6 +771,19 @@ struct ocfs2_write_ctxt { unsigned int w_unwritten_count; }; +void ocfs2_unlock_and_free_folios(struct folio **folios, int num_folios) +{ + int i; + + for(i = 0; i < num_folios; i++) { + if (!folios[i]) + continue; + folio_unlock(folios[i]); + folio_mark_accessed(folios[i]); + folio_put(folios[i]); + } +} + void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages) { int i; @@ -784,7 +797,7 @@ void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages) } } -static void ocfs2_unlock_pages(struct ocfs2_write_ctxt *wc) +static void ocfs2_unlock_folios(struct ocfs2_write_ctxt *wc) { int i; @@ -795,16 +808,16 @@ static void ocfs2_unlock_pages(struct ocfs2_write_ctxt *wc) */ if (wc->w_target_locked) { BUG_ON(!wc->w_target_folio); - for (i = 0; i < wc->w_num_pages; i++) { - if (&wc->w_target_folio->page == wc->w_pages[i]) { - wc->w_pages[i] = NULL; + for (i = 0; i < wc->w_num_folios; i++) { + if (wc->w_target_folio == wc->w_folios[i]) { + wc->w_folios[i] = NULL; break; } } folio_mark_accessed(wc->w_target_folio); folio_put(wc->w_target_folio); } - ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages); + ocfs2_unlock_and_free_folios(wc->w_folios, wc->w_num_folios); } static void ocfs2_free_unwritten_list(struct inode *inode, @@ -826,7 +839,7 @@ static void ocfs2_free_write_ctxt(struct inode *inode, struct ocfs2_write_ctxt *wc) { ocfs2_free_unwritten_list(inode, &wc->w_unwritten_list); - ocfs2_unlock_pages(wc); + ocfs2_unlock_folios(wc); brelse(wc->w_di_bh); kfree(wc); } @@ -922,8 +935,8 @@ static void ocfs2_write_failure(struct inode *inode, if (wc->w_target_folio) ocfs2_zero_new_buffers(wc->w_target_folio, from, to); - for(i = 0; i < wc->w_num_pages; i++) { - tmppage = wc->w_pages[i]; + for (i = 0; i < wc->w_num_folios; i++) { + tmppage = &wc->w_folios[i]->page; if (tmppage && page_has_buffers(tmppage)) { if (ocfs2_should_order_data(inode)) @@ -935,12 +948,11 @@ static void ocfs2_write_failure(struct inode *inode, } } -static int ocfs2_prepare_page_for_write(struct inode *inode, u64 *p_blkno, - struct ocfs2_write_ctxt *wc, - struct page *page, u32 cpos, - loff_t user_pos, unsigned user_len, - int new) +static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno, + struct ocfs2_write_ctxt *wc, struct folio *folio, u32 cpos, + loff_t user_pos, unsigned user_len, int new) { + struct page *page = &folio->page; int ret; unsigned int map_from = 0, map_to = 0; unsigned int cluster_start, cluster_end; @@ -1019,11 +1031,9 @@ static int ocfs2_prepare_page_for_write(struct inode *inode, u64 *p_blkno, /* * This function will only grab one clusters worth of pages. */ -static int ocfs2_grab_pages_for_write(struct address_space *mapping, - struct ocfs2_write_ctxt *wc, - u32 cpos, loff_t user_pos, - unsigned user_len, int new, - struct folio *mmap_folio) +static int ocfs2_grab_folios_for_write(struct address_space *mapping, + struct ocfs2_write_ctxt *wc, u32 cpos, loff_t user_pos, + unsigned user_len, int new, struct folio *mmap_folio) { int ret = 0, i; unsigned long start, target_index, end_index, index; @@ -1040,7 +1050,7 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping, * last page of the write. */ if (new) { - wc->w_num_pages = ocfs2_pages_per_cluster(inode->i_sb); + wc->w_num_folios = ocfs2_pages_per_cluster(inode->i_sb); start = ocfs2_align_clusters_to_page_index(inode->i_sb, cpos); /* * We need the index *past* the last page we could possibly @@ -1050,15 +1060,15 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping, last_byte = max(user_pos + user_len, i_size_read(inode)); BUG_ON(last_byte < 1); end_index = ((last_byte - 1) >> PAGE_SHIFT) + 1; - if ((start + wc->w_num_pages) > end_index) - wc->w_num_pages = end_index - start; + if ((start + wc->w_num_folios) > end_index) + wc->w_num_folios = end_index - start; } else { - wc->w_num_pages = 1; + wc->w_num_folios = 1; start = target_index; } end_index = (user_pos + user_len - 1) >> PAGE_SHIFT; - for(i = 0; i < wc->w_num_pages; i++) { + for(i = 0; i < wc->w_num_folios; i++) { index = start + i; if (index >= target_index && index <= end_index && @@ -1079,26 +1089,27 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping, } folio_get(mmap_folio); - wc->w_pages[i] = &mmap_folio->page; + wc->w_folios[i] = mmap_folio; wc->w_target_locked = true; } else if (index >= target_index && index <= end_index && wc->w_type == OCFS2_WRITE_DIRECT) { /* Direct write has no mapping page. */ - wc->w_pages[i] = NULL; + wc->w_folios[i] = NULL; continue; } else { - wc->w_pages[i] = find_or_create_page(mapping, index, - GFP_NOFS); - if (!wc->w_pages[i]) { - ret = -ENOMEM; + wc->w_folios[i] = __filemap_get_folio(mapping, index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, + GFP_NOFS); + if (IS_ERR(wc->w_folios[i])) { + ret = PTR_ERR(wc->w_folios[i]); mlog_errno(ret); goto out; } } - wait_for_stable_page(wc->w_pages[i]); + folio_wait_stable(wc->w_folios[i]); if (index == target_index) - wc->w_target_folio = page_folio(wc->w_pages[i]); + wc->w_target_folio = wc->w_folios[i]; } out: if (ret) @@ -1182,19 +1193,18 @@ static int ocfs2_write_cluster(struct address_space *mapping, if (!should_zero) p_blkno += (user_pos >> inode->i_sb->s_blocksize_bits) & (u64)(bpc - 1); - for(i = 0; i < wc->w_num_pages; i++) { + for (i = 0; i < wc->w_num_folios; i++) { int tmpret; /* This is the direct io target page. */ - if (wc->w_pages[i] == NULL) { + if (wc->w_folios[i] == NULL) { p_blkno += (1 << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits)); continue; } - tmpret = ocfs2_prepare_page_for_write(inode, &p_blkno, wc, - wc->w_pages[i], cpos, - user_pos, user_len, - should_zero); + tmpret = ocfs2_prepare_folio_for_write(inode, &p_blkno, wc, + wc->w_folios[i], cpos, user_pos, user_len, + should_zero); if (tmpret) { mlog_errno(tmpret); if (ret == 0) @@ -1493,12 +1503,12 @@ static int ocfs2_write_begin_inline(struct address_space *mapping, goto out; } /* - * If we don't set w_num_pages then this folio won't get unlocked + * If we don't set w_num_folios then this folio won't get unlocked * and freed on cleanup of the write context. */ wc->w_target_folio = folio; - wc->w_pages[0] = &folio->page; - wc->w_num_pages = 1; + wc->w_folios[0] = folio; + wc->w_num_folios = 1; ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, OCFS2_JOURNAL_ACCESS_WRITE); @@ -1791,18 +1801,18 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, } /* - * Fill our page array first. That way we've grabbed enough so + * Fill our folio array first. That way we've grabbed enough so * that we can zero and flush if we error after adding the * extent. */ - ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, len, - cluster_of_pages, mmap_folio); + ret = ocfs2_grab_folios_for_write(mapping, wc, wc->w_cpos, pos, len, + cluster_of_pages, mmap_folio); if (ret) { /* - * ocfs2_grab_pages_for_write() returns -EAGAIN if it could not lock - * the target page. In this case, we exit with no error and no target - * page. This will trigger the caller, page_mkwrite(), to re-try - * the operation. + * ocfs2_grab_folios_for_write() returns -EAGAIN if it + * could not lock the target folio. In this case, we exit + * with no error and no target folio. This will trigger + * the caller, page_mkwrite(), to re-try the operation. */ if (type == OCFS2_WRITE_MMAP && ret == -EAGAIN) { BUG_ON(wc->w_target_folio); @@ -1997,8 +2007,8 @@ int ocfs2_write_end_nolock(struct address_space *mapping, if (wc->w_target_folio) flush_dcache_folio(wc->w_target_folio); - for(i = 0; i < wc->w_num_pages; i++) { - tmppage = wc->w_pages[i]; + for (i = 0; i < wc->w_num_folios; i++) { + tmppage = &wc->w_folios[i]->page; /* This is the direct io target page. */ if (tmppage == NULL) @@ -2059,7 +2069,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping, * this lock and will ask for the page lock when flushing the data. * put it here to preserve the unlock order. */ - ocfs2_unlock_pages(wc); + ocfs2_unlock_folios(wc); if (handle) ocfs2_commit_trans(osb, handle); diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h index 1cb46072ad84..dcf4b0dc82c4 100644 --- a/fs/ocfs2/aops.h +++ b/fs/ocfs2/aops.h @@ -17,6 +17,7 @@ int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno, struct inode *inode, unsigned int from, unsigned int to, int new); +void ocfs2_unlock_and_free_folios(struct folio **folios, int num_folios); void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages); int walk_page_buffers( handle_t *handle, From patchwork Thu Dec 5 17:16:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895846 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 0DB23226ECA for ; Thu, 5 Dec 2024 17:17:04 +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=1733419027; cv=none; b=iOZDfi13vjAu8cQkxoxVEMfRTzP4qcvnT06ja+1bGmEDCRkdcp4oBDEIbVX5ptgZmR8dDOuYVcjSGUwF101FdvlCwB+q98rBwH2m0wxFgc+xjCboUPzy/HRrqDDqh5FT4s29GeaM0lETwmC8xvxD+gaGbP/tp+2pzK2+dodvRbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419027; c=relaxed/simple; bh=4uh3owOnSZjaoxsXk7FNl8fC0tvNlWWVruABwwaSTBQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f7NAlEC4of67rRmCN5jEVRVV30zSWwXtvG+ELtYGIogprT0CTkHIPVxLtQa/ZGyvTb2FAj+Y3MIMnJD6N5u/Bhrx/cJ2N7P/pNSH2k0GKT1f9J1lIhP2rdhYA+Mioa+e+Nd67NZnX3hQVcoCEdPRj/0yi/+4HIGiGWap7hP0sS4= 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=OZyqghzy; 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="OZyqghzy" 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=MSdYppceXEYTjnc1aF0xWK0TT1quRWa2DyXPATPSFUs=; b=OZyqghzynm1UKAZbrZ/j7CW8xQ PHFlpYDR46nLS0YKoOUBwHJ2jtsQ56iVJ4QW4OBTR1s9sKmCWz2QEn4lCWkD0/PZzmlj6omRpBjME L+YHhnvS8sVoSK1b8NTG2VMbDIHyubmTwAeZg5RnYjdUmjHpzuTxvMTVgp8Db1C3F7AGlzqrgL6k0 H0jtkT4gNp3CAIlO6m+Nl2JtUjk/X7JmDXQ0XEaiLOV6tSz00U+rTtHRBElH2zBQ+EAsLEfJcoKpa MK5GQlJFGuwpH6bCgJfGasH57Cjz9Rnja8khVob98kMbiD6ATKEzsFzzEA1U67nwGb7ZYPyRLvajR ofhOZTiA==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLGA-22VM; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 10/23] ocfs2: Convert ocfs2_write_failure() to use a folio Date: Thu, 5 Dec 2024 17:16:38 +0000 Message-ID: <20241205171653.3179945-11-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Remove the folio->page conversion and just use the folio. Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index afc20ab52b3e..8dda080743b7 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -930,20 +930,19 @@ static void ocfs2_write_failure(struct inode *inode, int i; unsigned from = user_pos & (PAGE_SIZE - 1), to = user_pos + user_len; - struct page *tmppage; if (wc->w_target_folio) ocfs2_zero_new_buffers(wc->w_target_folio, from, to); for (i = 0; i < wc->w_num_folios; i++) { - tmppage = &wc->w_folios[i]->page; + struct folio *folio = wc->w_folios[i]; - if (tmppage && page_has_buffers(tmppage)) { + if (folio && folio_buffers(folio)) { if (ocfs2_should_order_data(inode)) ocfs2_jbd2_inode_add_write(wc->w_handle, inode, user_pos, user_len); - block_commit_write(tmppage, from, to); + block_commit_write(&folio->page, from, to); } } } From patchwork Thu Dec 5 17:16:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895844 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 5261C226ECF for ; Thu, 5 Dec 2024 17:17:05 +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=1733419027; cv=none; b=FOgTNShXRsRJvij/09by6ClYP0FCpzcVGbfDLN1rpwnI8wXLH2/crtY9Rwct2n4lYGIp2JGZiraNRmEJY8b1R4INxFN5A8H60papVICi/VWGwArSwmC5nRkJuzMEF85QpDtY8vLTLacLPNfdspz/ryCx0cGtdx9LYcn9mxROI84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419027; c=relaxed/simple; bh=q97iOLYZh28Pzi/NTDtDX1YEulKdraYnePyT6i7EKDw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r3wrfphBR5Yl+hstU7pXiviH8o6/dXduAxbfFU9xdhjusC5scF39VAvZLnBT8G5QepQc4EJFlLzXQYKTVGrA71ImHDPiJs4Cf73kPU/wq2bJXk2P/DNelooRQvtKGgZ+XduVJb+9HmEkxcA6RVsn+Ajz9QKrSuRtFKJEsUb1F28= 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=fH65bsQQ; 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="fH65bsQQ" 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=OBUKwkpBr9YZoOfwJw0seJGO9CGQYHD0wrE36thU/L4=; b=fH65bsQQAr8YCu6PU3OIQmlUku 2TDXAM3xVu7seMImy8lAL3gLO3/TDXyRAOv5JZ8mFEhczgb6G0UEekYXw8R/s4fe/wILaFg2eLxl6 csFUDOIGX/CqSQ/brJhtZttQyBwEqduzoQ5fCNBRUqJ0sYciiln03BC/1DmDcsh7RCBPCuDbh94rT nlV5SXfrrYpNW/Fl37zGjIaZlf5fhTsGmltjCScdUXbA+NqQkLUJiYdoChku9idFdMaY7vzupFGEK T92UGPWhaKpfClwqy7Nq2uf/Ge0V9QNqAm6Xy2wcOjQdLzvHHCkSrCjFzY3EVyoJTmdJtjofjaOB9 j3sd6Daw==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLGC-2RKO; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 11/23] ocfs2: Use a folio in ocfs2_write_end_nolock() Date: Thu, 5 Dec 2024 17:16:39 +0000 Message-ID: <20241205171653.3179945-12-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Remove an access to page->index. Remove some PAGE_SIZE assumptions. Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 8dda080743b7..cc252a1170ad 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -1952,17 +1952,16 @@ static void ocfs2_write_end_inline(struct inode *inode, loff_t pos, le16_to_cpu(di->i_dyn_features)); } -int ocfs2_write_end_nolock(struct address_space *mapping, - loff_t pos, unsigned len, unsigned copied, void *fsdata) +int ocfs2_write_end_nolock(struct address_space *mapping, loff_t pos, + unsigned len, unsigned copied, void *fsdata) { int i, ret; - unsigned from, to, start = pos & (PAGE_SIZE - 1); + size_t from, to, start = pos & (PAGE_SIZE - 1); struct inode *inode = mapping->host; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct ocfs2_write_ctxt *wc = fsdata; struct ocfs2_dinode *di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; handle_t *handle = wc->w_handle; - struct page *tmppage; BUG_ON(!list_empty(&wc->w_unwritten_list)); @@ -1993,32 +1992,32 @@ int ocfs2_write_end_nolock(struct address_space *mapping, start+len); else { /* - * When page is fully beyond new isize (data copy - * failed), do not bother zeroing the page. Invalidate + * When folio is fully beyond new isize (data copy + * failed), do not bother zeroing the folio. Invalidate * it instead so that writeback does not get confused * put page & buffer dirty bits into inconsistent * state. */ - block_invalidate_folio(wc->w_target_folio, - 0, PAGE_SIZE); + block_invalidate_folio(wc->w_target_folio, 0, + folio_size(wc->w_target_folio)); } } if (wc->w_target_folio) flush_dcache_folio(wc->w_target_folio); for (i = 0; i < wc->w_num_folios; i++) { - tmppage = &wc->w_folios[i]->page; + struct folio *folio = wc->w_folios[i]; - /* This is the direct io target page. */ - if (tmppage == NULL) + /* This is the direct io target folio */ + if (folio == NULL) continue; - if (tmppage == &wc->w_target_folio->page) { + if (folio == wc->w_target_folio) { from = wc->w_target_from; to = wc->w_target_to; - BUG_ON(from > PAGE_SIZE || - to > PAGE_SIZE || + BUG_ON(from > folio_size(folio) || + to > folio_size(folio) || to < from); } else { /* @@ -2027,19 +2026,17 @@ int ocfs2_write_end_nolock(struct address_space *mapping, * to flush their entire range. */ from = 0; - to = PAGE_SIZE; + to = folio_size(folio); } - if (page_has_buffers(tmppage)) { + if (folio_buffers(folio)) { if (handle && ocfs2_should_order_data(inode)) { - loff_t start_byte = - ((loff_t)tmppage->index << PAGE_SHIFT) + - from; + loff_t start_byte = folio_pos(folio) + from; loff_t length = to - from; ocfs2_jbd2_inode_add_write(handle, inode, start_byte, length); } - block_commit_write(tmppage, from, to); + block_commit_write(&folio->page, from, to); } } From patchwork Thu Dec 5 17:16:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895843 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 4510B226ECC for ; Thu, 5 Dec 2024 17:17:05 +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=1733419026; cv=none; b=Nc7IcVcxXstQhc1qeW8TMdmwJK5SMF2WrjQzXfSyrQmOjjdROFmcB7qK3YZ6L4wxKqcsW4T75rzSFJpHDr4az59xnExoauJDqFmzfxp/RQrQnF6FY0jdtfgMgV+kGE+AKQPbWdfNosYPrt8T/WNzbmdcVTP0fvbDmb+6034XBvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419026; c=relaxed/simple; bh=fQvv5Sl7EZkIHkeHfZ48z5PGkR9/ySURx28UcBtDb70=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HFeBlYxCjrO55G7yqy4SsJb434Vw5nxoZ8IsrrJQAkPEnZJrB/HckQLl5bQQzpC/ZN27yr5raVfz8Z6Jv4T0VNap+D5W8uPSvUZmGb3RwwXB0OwRYGYcFmlEHTvGX2vl6A+rBAMYXi25rSVSNQAXoAJ2a74qppxvPKa4AdKgxC8= 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=sdnUCJQ0; 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="sdnUCJQ0" 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=ASxegapsLTTvXMrOJXt+9JDzCb9WinP9tSqjYHXc/JU=; b=sdnUCJQ0EAQffBYp3SnUmT79wo 9MX+V/0QzGk4T8Mel2s0vw0ZpfkFVhj/1pIn74ioxG1EWFje2ucMCe1xoWO2jQGvmoDpPATikC0k4 vTw1IjBH8ITtdaQq7tQOC4YI/Vyg7YCBwtfCM+5685Tl0bHtw109X4sZDSagIWlvBODNGN3cCW0w7 Sr0mBf2DSfhITjqzhRJKcCnpujn4ZVPGxAz2LdKHNO+dGRmjbco7NhtSbwvlIrPxwGUsMP1NS29lu w16tOZkD4+6Btvq/FB96BB2S3M1DeDnafWZHAnopDvRu7i1vbR7N1sTIkzfitWqAW+FR3OXIElyby LMBBs7Ig==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLGE-2p0Z; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 12/23] ocfs2: Use a folio in ocfs2_prepare_page_for_write() Date: Thu, 5 Dec 2024 17:16:40 +0000 Message-ID: <20241205171653.3179945-13-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Update to the new APIs. Removes a few page->folio conversions. Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index cc252a1170ad..9ce8debbd282 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -963,10 +963,10 @@ static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno, /* treat the write as new if the a hole/lseek spanned across * the page boundary. */ - new = new | ((i_size_read(inode) <= page_offset(page)) && - (page_offset(page) <= user_pos)); + new = new | ((i_size_read(inode) <= folio_pos(folio)) && + (folio_pos(folio) <= user_pos)); - if (page == &wc->w_target_folio->page) { + if (folio == wc->w_target_folio) { map_from = user_pos & (PAGE_SIZE - 1); map_to = map_from + user_len; @@ -990,7 +990,7 @@ static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno, } } else { /* - * If we haven't allocated the new page yet, we + * If we haven't allocated the new folio yet, we * shouldn't be writing it out without copying user * data. This is likely a math error from the caller. */ @@ -1008,20 +1008,20 @@ static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno, } /* - * Parts of newly allocated pages need to be zero'd. + * Parts of newly allocated folios need to be zero'd. * * Above, we have also rewritten 'to' and 'from' - as far as * the rest of the function is concerned, the entire cluster - * range inside of a page needs to be written. + * range inside of a folio needs to be written. * - * We can skip this if the page is up to date - it's already + * We can skip this if the folio is uptodate - it's already * been zero'd from being read in as a hole. */ - if (new && !PageUptodate(page)) + if (new && !folio_test_uptodate(folio)) ocfs2_clear_page_regions(page, OCFS2_SB(inode->i_sb), cpos, user_data_from, user_data_to); - flush_dcache_page(page); + flush_dcache_folio(folio); out: return ret; From patchwork Thu Dec 5 17:16:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895842 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 1D41C226ED0 for ; Thu, 5 Dec 2024 17:17:05 +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=1733419026; cv=none; b=ieQtcMA1yfa1jkapGEdAtdgYaEJgOlq7Avomgod4AuCAa/V2i2ofv5pPuYoVCcxGx7yi9qzlA2CF4Y8YrYLtU7xQAy1xdQPqLk3sXhN2Rpe+eeU6WFR1DlD/lj29Kh+VbrlmFhMmtuc18czw2bVC5UzIbL6ctBGs2R4JBfpW4b8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419026; c=relaxed/simple; bh=DiQg3NuuAyB2fjqC6JhPRp+mTwmtiq5pRjM2vNzkIs4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y8ud1JglZm4tSVhUEIvmZfNRf8qrmbMbtcQjET8fbjIhze2R1CuleKbf8yrSDxl4YeB7yueC/E9Mr9OyZvpyn+LHkxMqaY7B+7dzCeM4Ea3Ywj8OCoVmfUwcWZBriV5bfjAIvaOmDaqZKd72HI3FhQvgIG0dJ8gJb+fEBQKV4DI= 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=NPIGsN0d; 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="NPIGsN0d" 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=ydccpepzdYGSwuKz0r/ELU2Gl+SwBBvkmM9nlUYnk0s=; b=NPIGsN0di5QZ9M6yE5cDjSH/NN YHxHxEEiczirx9kMymJgOCshVnUS0oES92LwOnKVbuQHg4VQ8jLmAq2cwxyTLHZgBHq5Xz2pYQIlG nei9PuDkGS4BecNilk/6u+Fdg/YVi5Netq70HXV0TI66gQDjRPLvUdUsqOddNOrRloZd7hguqkdkj TeW9w5WoS02F73urPGqbi5259t2lQycztkxb2b5Isv+YPWgPUdJv7ZQAHuvbitbeo2WWOjc2PYYS8 5hZmceXXBM3coo6nwprkF8motJ+fRIm5wQaWfsvDupA3L1/c4Q6BpO+7TpzSkLQ+gHO9Rv/VErdwM 6x18xVJg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLGH-3CHM; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 13/23] ocfs2: Use a folio in ocfs2_map_and_dirty_page() Date: Thu, 5 Dec 2024 17:16:41 +0000 Message-ID: <20241205171653.3179945-14-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Convert the incoming page to a folio and use it throughout the function. Removes a couple of calls to compound_head(). Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/alloc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 395e23920632..e95fe65b6a74 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -6812,8 +6812,9 @@ void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, unsigned int from, unsigned int to, struct page *page, int zero, u64 *phys) { + struct folio *folio = page_folio(page); int ret, partial = 0; - loff_t start_byte = ((loff_t)page->index << PAGE_SHIFT) + from; + loff_t start_byte = folio_pos(folio) + from; loff_t length = to - from; ret = ocfs2_map_page_blocks(page, phys, inode, from, to, 0); @@ -6821,14 +6822,14 @@ void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, mlog_errno(ret); if (zero) - zero_user_segment(page, from, to); + folio_zero_segment(folio, from, to); /* * Need to set the buffers we zero'd into uptodate * here if they aren't - ocfs2_map_page_blocks() * might've skipped some */ - ret = walk_page_buffers(handle, page_buffers(page), + ret = walk_page_buffers(handle, folio_buffers(folio), from, to, &partial, ocfs2_zero_func); if (ret < 0) @@ -6841,9 +6842,9 @@ void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, } if (!partial) - SetPageUptodate(page); + folio_mark_uptodate(folio); - flush_dcache_page(page); + flush_dcache_folio(folio); } static void ocfs2_zero_cluster_pages(struct inode *inode, loff_t start, From patchwork Thu Dec 5 17:16:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895845 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 7E7DB226ED3 for ; Thu, 5 Dec 2024 17:17:05 +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=1733419027; cv=none; b=dSGDhwLVYXDEl5pQSoq2T7yEFezu+EsSwB4Thkd1l9lCQ87GWGwiLhUcOmlVDajXHeO6Ud9L5+qUcxJI6G29yIuwL0mIynYigRL4UJmDNYf92OMHkIw9duQSfZEq1nUyIQz8S7yUIw8xgNW+yLrepEFgFxRwBnFNiCOBGR6nHQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419027; c=relaxed/simple; bh=iseqTKMUGGF0fJcPqMbTcFfGBO8QqW/NoVRKhiEaVJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AueE3VocBTROQWyvXNAYb2CrSYQn8/nVFGFle2KR78cCeaNBTbBbxltAioGm8lDfaCm2rSkmOd2opSnCPCditc92jerTA4mzSp4/xMqXmKakBQsKEeYpWrefozFX9gN1hdPKu5q2Y21tN3a04Ex7pBbwphaHsdWCV+UjcFoyoO0= 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=PWTPYqac; 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="PWTPYqac" 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=dMxMCc0P/c8cd0V+QxP09KCPIo99vuZeMhIz5rvBEaY=; b=PWTPYqacJekKIKIAXJmc8hi3Qj BQJVU/EBShK4Phxw7anMcovqNIoBJsyDDFiaNS77weSeQw/j9hipbJ/uJGr2JoPz0/UpoebjbltMv xGayw0q9L6y3nFUZzO5LnDaI3E9Imj91PtLwiGBvnEzvulwUaPvWEHjdJDxRKRv/CPZrtGkAsLZux 6g3q0FbO7lr3C1AJofgXEJe1D8QWx0VOglZU8MQiwA2tQgI435Ssm0CCkSJ4X6djTftvDzhkSx3yA 9vYz6/joTSDyNtlpqwdlsIFYJS4t18YpYnXixb/F0pqwFJtWvmqPYuXE6rSnTbuDiFg9gxNRXsdaw tisU7wmw==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLGJ-3av3; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 14/23] ocfs2: Convert ocfs2_map_page_blocks() to ocfs2_map_folio_blocks() Date: Thu, 5 Dec 2024 17:16:42 +0000 Message-ID: <20241205171653.3179945-15-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely All callers now have a folio, so pass it in instead of converting folio->page->folio. Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/alloc.c | 2 +- fs/ocfs2/aops.c | 18 ++++++++---------- fs/ocfs2/aops.h | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index e95fe65b6a74..cfe9535a27f9 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -6817,7 +6817,7 @@ void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, loff_t start_byte = folio_pos(folio) + from; loff_t length = to - from; - ret = ocfs2_map_page_blocks(page, phys, inode, from, to, 0); + ret = ocfs2_map_folio_blocks(folio, phys, inode, from, to, 0); if (ret) mlog_errno(ret); diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 9ce8debbd282..cbc8bc6d95f3 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -560,7 +560,7 @@ static void ocfs2_clear_page_regions(struct page *page, /* * Nonsparse file systems fully allocate before we get to the write * code. This prevents ocfs2_write() from tagging the write as an - * allocating one, which means ocfs2_map_page_blocks() might try to + * allocating one, which means ocfs2_map_folio_blocks() might try to * read-in the blocks at the tail of our file. Avoid reading them by * testing i_size against each block offset. */ @@ -585,11 +585,10 @@ static int ocfs2_should_read_blk(struct inode *inode, struct folio *folio, * * This will also skip zeroing, which is handled externally. */ -int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno, +int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno, struct inode *inode, unsigned int from, unsigned int to, int new) { - struct folio *folio = page_folio(page); int ret = 0; struct buffer_head *head, *bh, *wait[2], **wait_bh = wait; unsigned int block_end, block_start; @@ -971,12 +970,11 @@ static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno, map_to = map_from + user_len; if (new) - ret = ocfs2_map_page_blocks(page, p_blkno, inode, - cluster_start, cluster_end, - new); + ret = ocfs2_map_folio_blocks(folio, p_blkno, inode, + cluster_start, cluster_end, new); else - ret = ocfs2_map_page_blocks(page, p_blkno, inode, - map_from, map_to, new); + ret = ocfs2_map_folio_blocks(folio, p_blkno, inode, + map_from, map_to, new); if (ret) { mlog_errno(ret); goto out; @@ -999,8 +997,8 @@ static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno, map_from = cluster_start; map_to = cluster_end; - ret = ocfs2_map_page_blocks(page, p_blkno, inode, - cluster_start, cluster_end, new); + ret = ocfs2_map_folio_blocks(folio, p_blkno, inode, + cluster_start, cluster_end, new); if (ret) { mlog_errno(ret); goto out; diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h index dcf4b0dc82c4..17ca359c6051 100644 --- a/fs/ocfs2/aops.h +++ b/fs/ocfs2/aops.h @@ -13,7 +13,7 @@ handle_t *ocfs2_start_walk_page_trans(struct inode *inode, unsigned from, unsigned to); -int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno, +int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno, struct inode *inode, unsigned int from, unsigned int to, int new); From patchwork Thu Dec 5 17:16:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895860 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 734C5226EF5 for ; Thu, 5 Dec 2024 17:17:31 +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=1733419053; cv=none; b=pxqDWcthZTsBIUiZH4AYu/2u89bL2VRxaqrUB8rlwHbbnS9p3ki8e7gj6P2SE8+NgTzO+5AlbOYOFLp2d5Mq8eMDI+kRJlc2+Gh97O6aja0oaRl4+JEO5UMixjXucqiLTLipNyejkag1tnQ73Bq/c9SzKiLOcSfqGMpXiMH1HIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419053; c=relaxed/simple; bh=WbZpgb0DkwTzuhnkaLq1TV9bIHxvUFhXyfXM/ATi154=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a6GxoXvzWdtNwOHt2+vyo4JTS7XALw1VsJ6YUOa9M4lOGWZfRt83SsZY9LZbfERj6+ZL5N5zjUnHLOwYlHJHj8uXEKE+Ex+VQb0Vp4Z1xDciI1McMXwjzHd6AuZeM2ThV2UWEeOQ+dAOn68BT7KNY2IlXfAGL3MWPaaSkpCtjaY= 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=wE/kzu1u; 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="wE/kzu1u" 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=oakCT1/9KQ1DlvRVJ74ykpyRT/wbvBHytrGAJv8/tdw=; b=wE/kzu1u67Z9TBmJQeVnbFDdkw AoD1P75KcU9c4NTTC3r3VH8TJcag3eAjenOUnwrOfC62wpGPDn3h8y6JatQMbX4+L8qD3xgHbXdXt Wkeli8QIs7FgaasMgKIUYf0v1TP+951klHuK5GW7E5K6ifsyYJ8cVni0hO5MbAGoNE8RfBOTEqkyN q/R8buc63D5S2ayNJtsz/otpqcxnjo40gy1BoFheLCBNlzStZXo5dvYFDlh1FpsOtn9yqHrA+8JMz +dtso7YauRPjslL7KE3HLyMfSkU7tPh6+1XEJJkoLpMxbJpmV5h3YYCz3gasb8q8gnSEd4R3437Cq FOGHOdTg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTG-0000000DLGL-403o; Thu, 05 Dec 2024 17:16:58 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 15/23] ocfs2: Convert ocfs2_clear_page_regions() to ocfs2_clear_folio_regions() Date: Thu, 5 Dec 2024 17:16:43 +0000 Message-ID: <20241205171653.3179945-16-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Pass in and use the folio instead of its page. Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index cbc8bc6d95f3..644680ac1414 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -534,7 +534,7 @@ static void ocfs2_figure_cluster_boundaries(struct ocfs2_super *osb, * * from == to == 0 is code for "zero the entire cluster region" */ -static void ocfs2_clear_page_regions(struct page *page, +static void ocfs2_clear_folio_regions(struct folio *folio, struct ocfs2_super *osb, u32 cpos, unsigned from, unsigned to) { @@ -543,7 +543,7 @@ static void ocfs2_clear_page_regions(struct page *page, ocfs2_figure_cluster_boundaries(osb, cpos, &cluster_start, &cluster_end); - kaddr = kmap_atomic(page); + kaddr = kmap_local_folio(folio, 0); if (from || to) { if (from > cluster_start) @@ -554,7 +554,7 @@ static void ocfs2_clear_page_regions(struct page *page, memset(kaddr + cluster_start, 0, cluster_end - cluster_start); } - kunmap_atomic(kaddr); + kunmap_local(kaddr); } /* @@ -950,7 +950,6 @@ static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno, struct ocfs2_write_ctxt *wc, struct folio *folio, u32 cpos, loff_t user_pos, unsigned user_len, int new) { - struct page *page = &folio->page; int ret; unsigned int map_from = 0, map_to = 0; unsigned int cluster_start, cluster_end; @@ -1016,7 +1015,7 @@ static int ocfs2_prepare_folio_for_write(struct inode *inode, u64 *p_blkno, * been zero'd from being read in as a hole. */ if (new && !folio_test_uptodate(folio)) - ocfs2_clear_page_regions(page, OCFS2_SB(inode->i_sb), + ocfs2_clear_folio_regions(folio, OCFS2_SB(inode->i_sb), cpos, user_data_from, user_data_to); flush_dcache_folio(folio); From patchwork Thu Dec 5 17:16:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895855 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 1DBAE224AFB for ; Thu, 5 Dec 2024 17:17:28 +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=1733419049; cv=none; b=DQ3s/A0Df1ZFRNRtl8YRdb8Z24+h6vgs1sC0LbNRiYhVN9rOt9gLJdS3ojoG4RZ0+Xjc7NgC3F+Zh2MHQMn/g0xWWW0/qs+r/T1u9EJOx3MYE9F4y3rmqqLyeVRUN4XrpcbGrDz2bYpKRMQia/bSYYX/0M+I5mPjn9nl1mR8j20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419049; c=relaxed/simple; bh=OqtAqBU1JHDTflB+VikG/uZdf7H+lHq42CU2l5c3fMg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oRBZx5QsiBOOpZNW+OwqYpjs4MqkSQNLDkgwXTxtHX/pt7NlUzta9y8isnJgk2D76DPqgwale0RYCNx51soLmyl5Gc0l3O25vBjR+M6XhFoixjg9Gv8e/lmKaF+VgVB/YCAlDxd5IwozMYOSMtmDDUk1cozdSNyY5lbFZEWqmVw= 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=nlKdTHQB; 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="nlKdTHQB" 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=X467615ct6BO++b+oSAS0NGcQBIfCniwxOWoz1RkTTY=; b=nlKdTHQBNDmMfYBtbkbMD6ABV5 2A1+XAQ1Q446ft4yqNg9SntMYspa3F+PcPqzVaONGO3dc/ecbYarTPn3yGwJ+vIjm67ohfy6Zh0J9 guUyu36FbO8qNl5bY2a+yAB/EsDVokFh7i4a4MzJ4JsGcv2McHAPcBQvUENAzKb+PACtdYhfr+lWZ AKk0awd5e3q3IxH5zMjOfbm++VNgAKdDlJLbiFIu/TnB/2v4lW9W3JmBKrGViZ/FyD7UF5DVTdToK q6o7VE51F+OtForxRvkzqOr31ifuBLhVitxW+qeaeOZGYAre3src/1COhrTRQ2PUh3FpzEKQ3eX7b 7Q6lHJIg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTH-0000000DLGO-0DvO; Thu, 05 Dec 2024 17:16:59 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 16/23] ocfs2: Use an array of folios instead of an array of pages Date: Thu, 5 Dec 2024 17:16:44 +0000 Message-ID: <20241205171653.3179945-17-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely The ocfs2_zero_cluster_folios() / ocfs2_grab_folios() / ocfs2_grab_eof_folios() family of functions pass around an array of pages. Convert them to pass around an array of folios. This removes the last caller of ocfs2_unlock_and_free_pages(), so delete it. Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/alloc.c | 98 ++++++++++++++++++++++++------------------------ fs/ocfs2/alloc.h | 2 - fs/ocfs2/aops.c | 13 ------- fs/ocfs2/aops.h | 1 - 4 files changed, 49 insertions(+), 65 deletions(-) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index cfe9535a27f9..dfcdafc11377 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -6847,87 +6847,87 @@ void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, flush_dcache_folio(folio); } -static void ocfs2_zero_cluster_pages(struct inode *inode, loff_t start, - loff_t end, struct page **pages, - int numpages, u64 phys, handle_t *handle) +static void ocfs2_zero_cluster_folios(struct inode *inode, loff_t start, + loff_t end, struct folio **folios, int numfolios, + u64 phys, handle_t *handle) { int i; - struct page *page; unsigned int from, to = PAGE_SIZE; struct super_block *sb = inode->i_sb; BUG_ON(!ocfs2_sparse_alloc(OCFS2_SB(sb))); - if (numpages == 0) + if (numfolios == 0) goto out; to = PAGE_SIZE; - for(i = 0; i < numpages; i++) { - page = pages[i]; + for (i = 0; i < numfolios; i++) { + struct folio *folio = folios[i]; from = start & (PAGE_SIZE - 1); - if ((end >> PAGE_SHIFT) == page->index) + if ((end >> PAGE_SHIFT) == folio->index) to = end & (PAGE_SIZE - 1); BUG_ON(from > PAGE_SIZE); BUG_ON(to > PAGE_SIZE); - ocfs2_map_and_dirty_page(inode, handle, from, to, page, 1, + ocfs2_map_and_dirty_page(inode, handle, from, to, &folio->page, 1, &phys); - start = (page->index + 1) << PAGE_SHIFT; + start = (folio->index + 1) << PAGE_SHIFT; } out: - if (pages) - ocfs2_unlock_and_free_pages(pages, numpages); + if (folios) + ocfs2_unlock_and_free_folios(folios, numfolios); } -int ocfs2_grab_pages(struct inode *inode, loff_t start, loff_t end, - struct page **pages, int *num) +static int ocfs2_grab_folios(struct inode *inode, loff_t start, loff_t end, + struct folio **folios, int *num) { - int numpages, ret = 0; + int numfolios, ret = 0; struct address_space *mapping = inode->i_mapping; unsigned long index; loff_t last_page_bytes; BUG_ON(start > end); - numpages = 0; + numfolios = 0; last_page_bytes = PAGE_ALIGN(end); index = start >> PAGE_SHIFT; do { - pages[numpages] = find_or_create_page(mapping, index, GFP_NOFS); - if (!pages[numpages]) { - ret = -ENOMEM; + folios[numfolios] = __filemap_get_folio(mapping, index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, GFP_NOFS); + if (IS_ERR(folios[numfolios])) { + ret = PTR_ERR(folios[numfolios]); mlog_errno(ret); goto out; } - numpages++; - index++; + index = folio_next_index(folios[numfolios]); + numfolios++; } while (index < (last_page_bytes >> PAGE_SHIFT)); out: if (ret != 0) { - if (pages) - ocfs2_unlock_and_free_pages(pages, numpages); - numpages = 0; + if (folios) + ocfs2_unlock_and_free_folios(folios, numfolios); + numfolios = 0; } - *num = numpages; + *num = numfolios; return ret; } -static int ocfs2_grab_eof_pages(struct inode *inode, loff_t start, loff_t end, - struct page **pages, int *num) +static int ocfs2_grab_eof_folios(struct inode *inode, loff_t start, loff_t end, + struct folio **folios, int *num) { struct super_block *sb = inode->i_sb; BUG_ON(start >> OCFS2_SB(sb)->s_clustersize_bits != (end - 1) >> OCFS2_SB(sb)->s_clustersize_bits); - return ocfs2_grab_pages(inode, start, end, pages, num); + return ocfs2_grab_folios(inode, start, end, folios, num); } /* @@ -6941,8 +6941,8 @@ static int ocfs2_grab_eof_pages(struct inode *inode, loff_t start, loff_t end, int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle, u64 range_start, u64 range_end) { - int ret = 0, numpages; - struct page **pages = NULL; + int ret = 0, numfolios; + struct folio **folios = NULL; u64 phys; unsigned int ext_flags; struct super_block *sb = inode->i_sb; @@ -6955,17 +6955,17 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle, return 0; /* - * Avoid zeroing pages fully beyond current i_size. It is pointless as - * underlying blocks of those pages should be already zeroed out and + * Avoid zeroing folios fully beyond current i_size. It is pointless as + * underlying blocks of those folios should be already zeroed out and * page writeback will skip them anyway. */ range_end = min_t(u64, range_end, i_size_read(inode)); if (range_start >= range_end) return 0; - pages = kcalloc(ocfs2_pages_per_cluster(sb), - sizeof(struct page *), GFP_NOFS); - if (pages == NULL) { + folios = kcalloc(ocfs2_pages_per_cluster(sb), + sizeof(struct folio *), GFP_NOFS); + if (folios == NULL) { ret = -ENOMEM; mlog_errno(ret); goto out; @@ -6986,18 +6986,18 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle, if (phys == 0 || ext_flags & OCFS2_EXT_UNWRITTEN) goto out; - ret = ocfs2_grab_eof_pages(inode, range_start, range_end, pages, - &numpages); + ret = ocfs2_grab_eof_folios(inode, range_start, range_end, folios, + &numfolios); if (ret) { mlog_errno(ret); goto out; } - ocfs2_zero_cluster_pages(inode, range_start, range_end, pages, - numpages, phys, handle); + ocfs2_zero_cluster_folios(inode, range_start, range_end, folios, + numfolios, phys, handle); /* - * Initiate writeout of the pages we zero'd here. We don't + * Initiate writeout of the folios we zero'd here. We don't * wait on them - the truncate_inode_pages() call later will * do that for us. */ @@ -7007,7 +7007,7 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle, mlog_errno(ret); out: - kfree(pages); + kfree(folios); return ret; } @@ -7060,7 +7060,7 @@ void ocfs2_set_inode_data_inline(struct inode *inode, struct ocfs2_dinode *di) int ocfs2_convert_inline_data_to_extents(struct inode *inode, struct buffer_head *di_bh) { - int ret, has_data, num_pages = 0; + int ret, has_data, num_folios = 0; int need_free = 0; u32 bit_off, num; handle_t *handle; @@ -7069,7 +7069,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; struct ocfs2_alloc_context *data_ac = NULL; - struct page *page = NULL; + struct folio *folio = NULL; struct ocfs2_extent_tree et; int did_quota = 0; @@ -7124,8 +7124,8 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, */ block = phys = ocfs2_clusters_to_blocks(inode->i_sb, bit_off); - ret = ocfs2_grab_eof_pages(inode, 0, page_end, &page, - &num_pages); + ret = ocfs2_grab_eof_folios(inode, 0, page_end, &folio, + &num_folios); if (ret) { mlog_errno(ret); need_free = 1; @@ -7136,14 +7136,14 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, * This should populate the 1st page for us and mark * it up to date. */ - ret = ocfs2_read_inline_data(inode, page, di_bh); + ret = ocfs2_read_inline_data(inode, &folio->page, di_bh); if (ret) { mlog_errno(ret); need_free = 1; goto out_unlock; } - ocfs2_map_and_dirty_page(inode, handle, 0, page_end, page, 0, + ocfs2_map_and_dirty_page(inode, handle, 0, page_end, &folio->page, 0, &phys); } @@ -7175,8 +7175,8 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, } out_unlock: - if (page) - ocfs2_unlock_and_free_pages(&page, num_pages); + if (folio) + ocfs2_unlock_and_free_folios(&folio, num_folios); out_commit: if (ret < 0 && did_quota) diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h index 4af7abaa6e40..6a2aca1a062e 100644 --- a/fs/ocfs2/alloc.h +++ b/fs/ocfs2/alloc.h @@ -254,8 +254,6 @@ static inline int ocfs2_is_empty_extent(struct ocfs2_extent_rec *rec) return !rec->e_leaf_clusters; } -int ocfs2_grab_pages(struct inode *inode, loff_t start, loff_t end, - struct page **pages, int *num); void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, unsigned int from, unsigned int to, struct page *page, int zero, u64 *phys); diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 644680ac1414..f1eba968563f 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -783,19 +783,6 @@ void ocfs2_unlock_and_free_folios(struct folio **folios, int num_folios) } } -void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages) -{ - int i; - - for(i = 0; i < num_pages; i++) { - if (pages[i]) { - unlock_page(pages[i]); - mark_page_accessed(pages[i]); - put_page(pages[i]); - } - } -} - static void ocfs2_unlock_folios(struct ocfs2_write_ctxt *wc) { int i; diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h index 17ca359c6051..cf8d202d9a8b 100644 --- a/fs/ocfs2/aops.h +++ b/fs/ocfs2/aops.h @@ -18,7 +18,6 @@ int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno, unsigned int to, int new); void ocfs2_unlock_and_free_folios(struct folio **folios, int num_folios); -void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages); int walk_page_buffers( handle_t *handle, struct buffer_head *head, From patchwork Thu Dec 5 17:16:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895856 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 1D427226EDE for ; Thu, 5 Dec 2024 17:17:31 +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=1733419052; cv=none; b=SPbGy8PzBuR9CuhoytmJGNe2Y/3UzSlmPtdhuVYdo2UXOSGsWet0pPem2SRoua5L9gFNYYj4rZXrrqvytyV61zscI49ebkkIa2LhFH4Kuf5S5CMidUFWJLiutxVfB3rD1ISYYfdO+xYPu+wI/wYsQOk1Mm/ngglarOMkE7slfOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419052; c=relaxed/simple; bh=wlv6N9lMsZJnyr5EjbhX0vGKk36/kJ+MsWhETXMfw+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AuMrcRb/kvoF28BUluOazklGKz+3GSPCMF67rWRAevmHmW4lFRU9oSM5VDkEhsvPUwYDcgiG0gXifR2/qfPhhwCv06o1Xob9EHFXbgxTz0L2P0yoIAMvGF+li3OTgXOTb5hzwAgtwv3DtAz8RKiERrNFHwmEcAKtgocICYSYogg= 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=DiCk+cr+; 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="DiCk+cr+" 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=OWPYwJHsbe8+Xvq+8+JVMaQlULm41wzo2YKYKt+QVME=; b=DiCk+cr+iePLUXOb73M9ortm6o kFTsPt7rYyJlEv73yZdExsnNUlgQWo6sV97X7Qyn0c38SgyR8bZIxq6Lh8d+2tMbde3u2HIHqDu4E sUkfHhtNqRnF+j7zwNg4BGhFKnjjNp4zKdSLprLTeKMonm/syLINf4He4Y9oL1cPthRAYxY0oWyV9 Qn0FbnXWtdO94aSTAIY6oDXNEgSIsSoq/uubSbxo3HAQZ1WbWJ54BDJhpP2Omzr1ghXmIcovksLky eP9OI7QRcVDlATD34NaAmqpbaUfCG6Tik8WrTB3R8MDwWrb7ev+HVQ72KgCu7hMUwnprWrW771A3b QRqrWT2A==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTH-0000000DLGR-0abt; Thu, 05 Dec 2024 17:16:59 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 17/23] ocfs2: Convert ocfs2_duplicate_clusters_by_page() to use a folio Date: Thu, 5 Dec 2024 17:16:45 +0000 Message-ID: <20241205171653.3179945-18-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Retrieve folios from the page cache, not pages, and use a folio throughout this function. Removes seven calls to compound_head(). Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/refcounttree.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 004393b13c0a..68e0339690e9 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -2902,7 +2902,6 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, int ret = 0, partial; struct super_block *sb = inode->i_sb; u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster); - struct page *page; pgoff_t page_index; unsigned int from, to; loff_t offset, end, map_end; @@ -2921,6 +2920,7 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, end = i_size_read(inode); while (offset < end) { + struct folio *folio; page_index = offset >> PAGE_SHIFT; map_end = ((loff_t)page_index + 1) << PAGE_SHIFT; if (map_end > end) @@ -2933,9 +2933,10 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, to = map_end & (PAGE_SIZE - 1); retry: - page = find_or_create_page(mapping, page_index, GFP_NOFS); - if (!page) { - ret = -ENOMEM; + folio = __filemap_get_folio(mapping, page_index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, GFP_NOFS); + if (IS_ERR(folio)) { + ret = PTR_ERR(folio); mlog_errno(ret); break; } @@ -2945,9 +2946,9 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, * page, so write it back. */ if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize) { - if (PageDirty(page)) { - unlock_page(page); - put_page(page); + if (folio_test_dirty(folio)) { + folio_unlock(folio); + folio_put(folio); ret = filemap_write_and_wait_range(mapping, offset, map_end - 1); @@ -2955,9 +2956,7 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, } } - if (!PageUptodate(page)) { - struct folio *folio = page_folio(page); - + if (!folio_test_uptodate(folio)) { ret = block_read_full_folio(folio, ocfs2_get_block); if (ret) { mlog_errno(ret); @@ -2966,8 +2965,8 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, folio_lock(folio); } - if (page_has_buffers(page)) { - ret = walk_page_buffers(handle, page_buffers(page), + if (folio_buffers(folio)) { + ret = walk_page_buffers(handle, folio_buffers(folio), from, to, &partial, ocfs2_clear_cow_buffer); if (ret) { @@ -2978,12 +2977,11 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, ocfs2_map_and_dirty_page(inode, handle, from, to, - page, 0, &new_block); - mark_page_accessed(page); + &folio->page, 0, &new_block); + folio_mark_accessed(folio); unlock: - unlock_page(page); - put_page(page); - page = NULL; + folio_unlock(folio); + folio_put(folio); offset = map_end; if (ret) break; From patchwork Thu Dec 5 17:16:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895840 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 A037322579D for ; Thu, 5 Dec 2024 17:17:01 +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=1733419023; cv=none; b=QfL+PPKvmlkLPMx0oHdxzw6YfaxdZCZdSKZ3OsoVaC2KNP40B5TaHrx+2KQuAut9Wr43mBLakPF1eU2MKXuLeRms9pIHdsSxYGoGEV1UL0udUl63NN2LZsyynbFlnwu10X2T7pS1j3EazkTFBioOyv287+a1+a1jvPDGDX8b/oQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419023; c=relaxed/simple; bh=uFeWHBGTjdPxajyLI5qqpAR4Ejy3DGLOS9zTG5Fdkdo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rr0ooSwsggZ/RLpT3n/kUX6oiZIMOroAL2c7juHJ+ayPezm9ETZhPB/j+P7o3WAsbep1yfom+ezfOX6jpR7yvhQGMIEgoHtDr2bQGYLKq1KiDiNEb+sFKWotKi8bkT8k3b/FT9dn8AGQjc1IA0hXSUOIAgFtSoTIF8SNxD3/cWs= 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=FJ3CJRC5; 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="FJ3CJRC5" 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=72BKIgdnaEH0NqQiIR5xnue352hkq41VyzkpRVNz0Q8=; b=FJ3CJRC5zVsSv5SydpU+3CvYAL Q2NP9ZlAokNR7QB3yvtRkbD1uBLJCT8R7JvfKFF4aDLZZMrK2lkn/0UskCIl2KG/4jBzyY6bz03xr 9zmNaL25aPJfCgmgjBj1FNSnuc9lA05lsp6QxCWOw2GiQ2ILRKEzsRXCIvxHh+CH/CIg3Q5LCfXpR mzl8vAkszA/F7ZHPwJgGJmGyFKMfy2sJzsQ9qyMQSNJd2/Gg99yx/6jtNZloIdkVWTxvvh/VuBiWF 97ldk9R+C1a3HyastQuVYkQSGro8WQOL0sy4RFqQ/vh2A5o1QMQMQu0hLkari/oWtTw77DmxGubKv Ydc0pv1g==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTH-0000000DLGT-1E4k; Thu, 05 Dec 2024 17:16:59 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 18/23] ocfs2: Convert ocfs2_map_and_dirty_page() to ocfs2_map_and_dirty_folio() Date: Thu, 5 Dec 2024 17:16:46 +0000 Message-ID: <20241205171653.3179945-19-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely All callers now have a folio, so skip the folio->page->folio conversion. Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/alloc.c | 17 ++++++++--------- fs/ocfs2/alloc.h | 6 +++--- fs/ocfs2/refcounttree.c | 5 ++--- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index dfcdafc11377..c8d9d5e9a7fd 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -6808,11 +6808,10 @@ static int ocfs2_zero_func(handle_t *handle, struct buffer_head *bh) return 0; } -void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, - unsigned int from, unsigned int to, - struct page *page, int zero, u64 *phys) +void ocfs2_map_and_dirty_folio(struct inode *inode, handle_t *handle, + size_t from, size_t to, struct folio *folio, int zero, + u64 *phys) { - struct folio *folio = page_folio(page); int ret, partial = 0; loff_t start_byte = folio_pos(folio) + from; loff_t length = to - from; @@ -6871,8 +6870,8 @@ static void ocfs2_zero_cluster_folios(struct inode *inode, loff_t start, BUG_ON(from > PAGE_SIZE); BUG_ON(to > PAGE_SIZE); - ocfs2_map_and_dirty_page(inode, handle, from, to, &folio->page, 1, - &phys); + ocfs2_map_and_dirty_folio(inode, handle, from, to, folio, 1, + &phys); start = (folio->index + 1) << PAGE_SHIFT; } @@ -7120,7 +7119,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, /* * Save two copies, one for insert, and one that can - * be changed by ocfs2_map_and_dirty_page() below. + * be changed by ocfs2_map_and_dirty_folio() below. */ block = phys = ocfs2_clusters_to_blocks(inode->i_sb, bit_off); @@ -7143,8 +7142,8 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, goto out_unlock; } - ocfs2_map_and_dirty_page(inode, handle, 0, page_end, &folio->page, 0, - &phys); + ocfs2_map_and_dirty_folio(inode, handle, 0, page_end, folio, 0, + &phys); } spin_lock(&oi->ip_lock); diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h index 6a2aca1a062e..1c0c83362904 100644 --- a/fs/ocfs2/alloc.h +++ b/fs/ocfs2/alloc.h @@ -254,9 +254,9 @@ static inline int ocfs2_is_empty_extent(struct ocfs2_extent_rec *rec) return !rec->e_leaf_clusters; } -void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, - unsigned int from, unsigned int to, - struct page *page, int zero, u64 *phys); +void ocfs2_map_and_dirty_folio(struct inode *inode, handle_t *handle, + size_t from, size_t to, struct folio *folio, int zero, + u64 *phys); /* * Structures which describe a path through a btree, and functions to * manipulate them. diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 68e0339690e9..693665a36855 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -2975,9 +2975,8 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, } } - ocfs2_map_and_dirty_page(inode, - handle, from, to, - &folio->page, 0, &new_block); + ocfs2_map_and_dirty_folio(inode, handle, from, to, + folio, 0, &new_block); folio_mark_accessed(folio); unlock: folio_unlock(folio); From patchwork Thu Dec 5 17:16:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895848 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 5C30E226ED6 for ; Thu, 5 Dec 2024 17:17:07 +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=1733419028; cv=none; b=Z+AIqpimXNg23AQRAfeRqUdu8GgGaJ2oOy9YOngEuZkCwM+YW59315wXv8OU8S9xfBF8p8LqeEG0tcfx5OrWjMspkPNHec3um2hy/J57IG+T7WMBHI17fdIFYSYAzMT+WtOx4jjQ/e5RpIgCOMtPTl0/wZaoNbJFetPK4XaM6cU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419028; c=relaxed/simple; bh=sz/1TgSG/YFjVIblpFHI84bB/oYWk8dsdXtDiQQjyaw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ByPdpZzBh7OJ0bdWYXqMc/9wM9uusk9X3eDKOWUA5GqtXtGmseyWgx77hiGY0u2ARg7R8NWkWJehrRdH1gKObAhT8g13Ktv8lZ4m+VyHnxNAHMkEpntv8p1Ox6fc6MWodp0SDmLeBDQLYmqHIgnTTHFQO6KJdyO/zU59vb8tCU0= 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=IgyNPUxS; 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="IgyNPUxS" 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=KblIVmxpEco2yqyBjKmuEMH7jBMf12lFTg6fcR2SQyk=; b=IgyNPUxSrJHr23SHGexJPhZUHS SnI8v99YPSMFXaL/oMNvtD9OT5wXPxIJBaqyrflRwsiK4Xzy6MeaCid0pbRiQUdqsqXB3Am9VlN6i iW8lsRRmX0nF1L9nJZIg7WHLTDLZnIucGRkpjrwxW500AXrTeNVz3l/NS8MLuTixhxzG9MXz+IZ6O 2+z8GOP4m4EGRkDBRUY+jb6le2ZCWmFTIFGZXSOyR2rlWb36gN6vRiU5fSFxH17isnsbcWbFzeA8a NNMGolweXU4f2S4nO+f7EZKYNeOb5gX1fzwnKMzTd2+/M3CkdQKOVwEdNfLkDgHxiYZzAh+59TUQ1 8Bd9r1DA==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTH-0000000DLGY-2E03; Thu, 05 Dec 2024 17:16:59 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: "Matthew Wilcox (Oracle)" , ocfs2-devel@lists.linux.dev, Mark Tinguely Subject: [PATCH 19/23] ocfs2: Convert ocfs2_read_inline_data() to take a folio Date: Thu, 5 Dec 2024 17:16:47 +0000 Message-ID: <20241205171653.3179945-20-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All callers now have a folio, so pass it in. We can use folio_fill_tail() instead of open-coding it. Saves a call to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/alloc.c | 2 +- fs/ocfs2/aops.c | 20 ++++++-------------- fs/ocfs2/aops.h | 2 +- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index c8d9d5e9a7fd..36b536b54a2d 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -7135,7 +7135,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, * This should populate the 1st page for us and mark * it up to date. */ - ret = ocfs2_read_inline_data(inode, &folio->page, di_bh); + ret = ocfs2_read_inline_data(inode, folio, di_bh); if (ret) { mlog_errno(ret); need_free = 1; diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index f1eba968563f..80fe7a68cbcc 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -215,10 +215,9 @@ int ocfs2_get_block(struct inode *inode, sector_t iblock, return err; } -int ocfs2_read_inline_data(struct inode *inode, struct page *page, +int ocfs2_read_inline_data(struct inode *inode, struct folio *folio, struct buffer_head *di_bh) { - void *kaddr; loff_t size; struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; @@ -230,7 +229,7 @@ int ocfs2_read_inline_data(struct inode *inode, struct page *page, size = i_size_read(inode); - if (size > PAGE_SIZE || + if (size > folio_size(folio) || size > ocfs2_max_inline_data_with_xattr(inode->i_sb, di)) { ocfs2_error(inode->i_sb, "Inode %llu has with inline data has bad size: %Lu\n", @@ -239,15 +238,8 @@ int ocfs2_read_inline_data(struct inode *inode, struct page *page, return -EROFS; } - kaddr = kmap_atomic(page); - if (size) - memcpy(kaddr, di->id2.i_data.id_data, size); - /* Clear the remaining part of the page */ - memset(kaddr + size, 0, PAGE_SIZE - size); - flush_dcache_page(page); - kunmap_atomic(kaddr); - - SetPageUptodate(page); + folio_fill_tail(folio, 0, di->id2.i_data.id_data, size); + folio_mark_uptodate(folio); return 0; } @@ -266,7 +258,7 @@ static int ocfs2_readpage_inline(struct inode *inode, struct folio *folio) goto out; } - ret = ocfs2_read_inline_data(inode, &folio->page, di_bh); + ret = ocfs2_read_inline_data(inode, folio, di_bh); out: folio_unlock(folio); @@ -1506,7 +1498,7 @@ static int ocfs2_write_begin_inline(struct address_space *mapping, ocfs2_set_inode_data_inline(inode, di); if (!folio_test_uptodate(folio)) { - ret = ocfs2_read_inline_data(inode, &folio->page, wc->w_di_bh); + ret = ocfs2_read_inline_data(inode, folio, wc->w_di_bh); if (ret) { ocfs2_commit_trans(osb, handle); diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h index cf8d202d9a8b..6f25066e5756 100644 --- a/fs/ocfs2/aops.h +++ b/fs/ocfs2/aops.h @@ -41,7 +41,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, struct folio **foliop, void **fsdata, struct buffer_head *di_bh, struct folio *mmap_folio); -int ocfs2_read_inline_data(struct inode *inode, struct page *page, +int ocfs2_read_inline_data(struct inode *inode, struct folio *folio, struct buffer_head *di_bh); int ocfs2_size_fits_inline_data(struct buffer_head *di_bh, u64 new_size); From patchwork Thu Dec 5 17:16:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895847 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 35564226EC0 for ; Thu, 5 Dec 2024 17:17:05 +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=1733419027; cv=none; b=HL94hdVA+KhniKF6uSfxExM0TodLn0pvZdckC0sLBIfU4GjHVcF8kABisb+ZN2qXH+wEwIR+lcnMdkRwWUvnlwuUb3gkhas4CQHGn3MN57Of8HBrDv5xgzxjWN4Sa9LatfeCpu+ZIQYq1dZmSfcvQRB6Jqa9Nb7FopB8YHw3wi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419027; c=relaxed/simple; bh=W2v4rWsDi/D2SdB5Ty8FhLHqH2YU7rifzTjjEU9FzpA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=STVZEXz4BBGwGi3pSxOrvOrji5P8THzDGt9go+KGKH/i1RFzQKzOJmqZ5o5QzHQEicy75c6M3BgRRWuDg3oHgt+XAAFEJzuT8tqxEGSpZvE1CyD4IkbCZ3kFuA0vInbmuVrnbZ4qiE1oejHWjhoouaSpH6ruvdPwMlcBXVEkikk= 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=WoRS9W+9; 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="WoRS9W+9" 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=aoFBEJy3t2lnyigM9xGluV10jv+W6viEU9rPL1tW/Vs=; b=WoRS9W+9R6Ak4QN1zsjVAGB0+V yKF+ildHMDvckh3zicpMcBH/PgnVneVm4EDFBsLkTozjiAuiSxO3+SjizfMBIzBA5SaTw3j/sZyKD K7h3/rGBkpS3XCuUV9CfXeSesoZoOC6Tq13qx/p78LHZHlXavWt5k/Cb+wmQ+e1rv0ccAZ6Uhsv/n xcGSCsqsD3e4AnOanN44675+Atj0VvTHpUn2Y6yg/I1PimvAP80LFEG+1wNvfFw9tCMmHqzqStXtZ +yoMF6067PWm3qi2BAfT0yGNw+gXJIiVHHe7/P/Rs2mxp9zol/D8EmH2CTJEO+YaicpB8OYZovLI7 4GoUF2MA==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTH-0000000DLGb-2aP0; Thu, 05 Dec 2024 17:16:59 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: "Matthew Wilcox (Oracle)" , ocfs2-devel@lists.linux.dev, Mark Tinguely Subject: [PATCH 20/23] ocfs2: Use a folio in ocfs2_fast_symlink_read_folio() Date: Thu, 5 Dec 2024 17:16:48 +0000 Message-ID: <20241205171653.3179945-21-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use folio_end_read() instead of SetPageUptodate() and unlock_page(). Use memcpy_to_folio() instead of open-coding a kmap_atomic() sequence. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/symlink.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index f5cf2255dc09..ad8be3300b49 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c @@ -54,13 +54,11 @@ static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio) { - struct page *page = &folio->page; - struct inode *inode = page->mapping->host; + struct inode *inode = folio->mapping->host; struct buffer_head *bh = NULL; int status = ocfs2_read_inode_block(inode, &bh); struct ocfs2_dinode *fe; const char *link; - void *kaddr; size_t len; if (status < 0) { @@ -72,12 +70,9 @@ static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio) link = (char *) fe->id2.i_symlink; /* will be less than a page size */ len = strnlen(link, ocfs2_fast_symlink_chars(inode->i_sb)); - kaddr = kmap_atomic(page); - memcpy(kaddr, link, len + 1); - kunmap_atomic(kaddr); - SetPageUptodate(page); + memcpy_to_folio(folio, 0, link, len + 1); out: - unlock_page(page); + folio_end_read(folio, status == 0); brelse(bh); return status; } From patchwork Thu Dec 5 17:16:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895859 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 602D2226EF2 for ; Thu, 5 Dec 2024 17:17:31 +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=1733419053; cv=none; b=jFL90HSpnp41lSb6XWDlrpS6qtPyzv3ap5dmw+IaQJtXUBn47oXAC8ulRak28m6iT2h9+2I9TFhIzYZW19uWJIhxEIEe5G3mwqjun+RlEletGEICGuIlzfVLB0V3ujNyOjpsB4qXubhqev1BbzC7BPtbs6EIBWZLTn3C1ONaK84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419053; c=relaxed/simple; bh=HCl20eVALTjXTp/pxsVCW9c1f6nWqHUrsxFDM6U5ZPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W8BGRgdZbs87J7uapEM7ftdOiZH4F1zvt8N8j7HS7kA00NQq7W8Ce0NxHa4NO8mx0Sxq/wIicAbjBk+Di1xosZ1a/o2m4FmKOGMZQRQlVnUlHussF+n9EO+nbqyAKSJ5KFZho+5yAZ05X21arDZo2ENY+/rKtF6UWOTw7q5AWe8= 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=lhPHOVA1; 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="lhPHOVA1" 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=BSqXbzYdnaJzeQ/U3q7JbAVD/yve3KYdDozgTsBb6WY=; b=lhPHOVA1rvxytxIKjVgTNqg4W5 oA4dh6xzuA/gzFHekTaJ+kZaCP/icuCuI2FB0QMT8wYveeNIy0xpz3QMR4h3Ve7DdixaUjuS4UY2N GD/h33nhn4rP133BjXMEh44b49+rJcrvp7tldb2eKUBXc2ByziAvEgz0Cbb5a4HcSqvycPRTYnNSt hpla2o4yXSKT7gCYgMIph7oAh53kFtCZrymwJG7YSTwf/pd8Caee9nQoDrjH6mJOOeEA/vUTt5JnO PtS6t/2sZksWopozaJH6E10ysEBKAGie/OoD3S5rcRWQiS4Ihdhqcgt9WWNdnMbrn/IYFwOOXBwZl 0lEpO0zg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTH-0000000DLGd-2wXk; Thu, 05 Dec 2024 17:16:59 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: "Matthew Wilcox (Oracle)" , ocfs2-devel@lists.linux.dev, Mark Tinguely Subject: [PATCH 21/23] ocfs2: Remove ocfs2_start_walk_page_trans() prototype Date: Thu, 5 Dec 2024 17:16:49 +0000 Message-ID: <20241205171653.3179945-22-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This function no longer exists. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/aops.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h index 6f25066e5756..114efc9111e4 100644 --- a/fs/ocfs2/aops.h +++ b/fs/ocfs2/aops.h @@ -8,11 +8,6 @@ #include -handle_t *ocfs2_start_walk_page_trans(struct inode *inode, - struct page *page, - unsigned from, - unsigned to); - int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno, struct inode *inode, unsigned int from, unsigned int to, int new); From patchwork Thu Dec 5 17:16:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895839 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 A044222579F for ; Thu, 5 Dec 2024 17:17:01 +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=1733419023; cv=none; b=NlFII6sHJmBv6aL6AvhG6SyvrzBi/29/qcKJPHW53LAWghcKVL5WBEA9sjw5Qcz+rBmMVwrA1XRvTFvEd86n+lHRLlC1CjW1qwnH0V783qp2LMEHFyWVJL3qsUvGLf4tFCL2sNBHeg65EJmAZOd6hyATcvruoF8LbkVaK6h8cgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419023; c=relaxed/simple; bh=H1yOemQFTMZ0muW/AU4827FjAk2NFjOHZy55MorHuTY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VaNK1KqTNztciFvMRXU9S33BeGj2hZHfGkSZEU2hVrZskG/3zOArWI1Fw1ns72EE1kL7cVnRAap919zKIlBZW89Izdpt+3CpKC6zqdawTXUmQocXkCP3G0JA46Vo3un+xQMof15Ttx/228QIWh1yB9akQ5lAtVvwOeTFi1sgq8o= 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=hEDUeKmR; 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="hEDUeKmR" 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=CAYIV0lvBXBf6GuA7JjRogDKn8RDhTxg8nqbcVw6i3E=; b=hEDUeKmRbVRaq2YH2iPYdRFLsk 5E8w7nhYu5fvabpYB+jhX3HEXgHkgciSduU/2LQmulY/Tlr9BcvDPlSj15NWmX/8fbZvusGF8R8ez +RBR1yDGjYdlFdAf4XzkdM1jqdWxoVeP26b2Cx8YgNOO7UkoW0PRgJn8ladCGZjDmfgs/nEIpgqX+ +8DpkAVGcGgi+XuvuCs0w17I4MHrrqgHYWPiqJILU3EyWFAxvm0NHTWtZZtUP7fCdZHm7QxmAS0Yn awCMjnuWHkH+CJMOFIlsQzWQBllkC10iieZhnTHidTWVsPMEbMEOJJovhaZsqTz/UFK7cbjVHPfvd KRcroegA==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTH-0000000DLGf-3XgO; Thu, 05 Dec 2024 17:16:59 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 22/23] ocfs2: Support large folios in ocfs2_zero_cluster_folios() Date: Thu, 5 Dec 2024 17:16:50 +0000 Message-ID: <20241205171653.3179945-23-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Remove assumptions that a folio is one page in size. Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/alloc.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 36b536b54a2d..3bff9314f8e0 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -6851,7 +6851,6 @@ static void ocfs2_zero_cluster_folios(struct inode *inode, loff_t start, u64 phys, handle_t *handle) { int i; - unsigned int from, to = PAGE_SIZE; struct super_block *sb = inode->i_sb; BUG_ON(!ocfs2_sparse_alloc(OCFS2_SB(sb))); @@ -6859,21 +6858,18 @@ static void ocfs2_zero_cluster_folios(struct inode *inode, loff_t start, if (numfolios == 0) goto out; - to = PAGE_SIZE; for (i = 0; i < numfolios; i++) { struct folio *folio = folios[i]; + size_t to = folio_size(folio); + size_t from = offset_in_folio(folio, start); - from = start & (PAGE_SIZE - 1); - if ((end >> PAGE_SHIFT) == folio->index) - to = end & (PAGE_SIZE - 1); - - BUG_ON(from > PAGE_SIZE); - BUG_ON(to > PAGE_SIZE); + if (to > end - folio_pos(folio)) + to = end - folio_pos(folio); ocfs2_map_and_dirty_folio(inode, handle, from, to, folio, 1, &phys); - start = (folio->index + 1) << PAGE_SHIFT; + start = folio_next_index(folio) << PAGE_SHIFT; } out: if (folios) From patchwork Thu Dec 5 17:16:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895838 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 A03EB22579E for ; Thu, 5 Dec 2024 17:17:01 +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=1733419023; cv=none; b=U1NAj1UZ04YOi8HZhSZhJ/rCB0pvTtaQxwEnpZkAXZAfCF2d+33YQXxEjlG7/zF5xUZCgjZdA5HCJLki8SLZwesJuva/O1c/5z4qZVlI3eirra8DtkxSbyj1QoDzR5KaF9m/ReS5SzOhVwKTfttuDeWWJluYEl4cF0QQStjU8+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733419023; c=relaxed/simple; bh=K03pF7muZLmclFpyZ5HmSUYnwpW3zKL/boAmKJjUyCk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tAlpu0bjYzXof/PAItp6BT7h0kn/h6OL5SthxdgCCR0id8B7MYQypII4o9QlV3mV6GdBCPhI1UK+nUZxAczQbUZr8ugJY7v5gJ76Fb8SIPUTgsETBKt0/YdQDdKMA5QhRZKI4ZGjrl2vm2F9yxuk5SBj6oYd0izdzCUpidH4Uc8= 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=hDAlH0gD; 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="hDAlH0gD" 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=GM5d3SLXzgiDV1eciPnvev6d2bEAOOquCnJNNKVhHV8=; b=hDAlH0gDrfghlPDqZx9ZhPnErb qaSGs1h0mzWcHcLiCJZoKgotpjOnA+NFgDm4dOQoB8GYLWlopYiig7Cu1n1kg6h7JNZ3rWp+wcnTD xD2m99xcDyoOmWrPR2/PLcXjebI7nfcAUfS1Smy8PUYAOo+dASGEzAgDeSAd7IOX/kCaCCXsRX8e1 LRzQAPhEyrJCMYecbjHndvGo9ikTPLa1Ds4gzn7MioXZc8pvxwYJRZHVaMlghq+R3goEQjY7Yo8WF MSQIIqtU/7QTM//ZK9MrvdsEQb4aG637GQmQTbC6uZ3Qf3spHcHQlGvoZ2N8AY7B7reico777OvfY dUrS/Vfw==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFTH-0000000DLH4-42Ss; Thu, 05 Dec 2024 17:16:59 +0000 From: "Matthew Wilcox (Oracle)" To: Joseph Qi Cc: Mark Tinguely , ocfs2-devel@lists.linux.dev, "Matthew Wilcox (Oracle)" Subject: [PATCH 23/23] ocfs2: Support large folios in ocfs2_write_zero_page() Date: Thu, 5 Dec 2024 17:16:51 +0000 Message-ID: <20241205171653.3179945-24-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205171653.3179945-1-willy@infradead.org> References: <20241205171653.3179945-1-willy@infradead.org> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mark Tinguely Remove assumptions that a folio is PAGE_SIZE. Signed-off-by: Mark Tinguely Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Joseph Qi --- fs/ocfs2/file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 957ced628eb1..e54f2c4b5a90 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -782,11 +782,11 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from, goto out_commit_trans; } - /* Get the offsets within the page that we want to zero */ - zero_from = abs_from & (PAGE_SIZE - 1); - zero_to = abs_to & (PAGE_SIZE - 1); + /* Get the offsets within the folio that we want to zero */ + zero_from = offset_in_folio(folio, abs_from); + zero_to = offset_in_folio(folio, abs_to); if (!zero_to) - zero_to = PAGE_SIZE; + zero_to = folio_size(folio); trace_ocfs2_write_zero_page( (unsigned long long)OCFS2_I(inode)->ip_blkno,