From patchwork Mon Apr 24 05:49:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13221657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77DF5C77B73 for ; Mon, 24 Apr 2023 05:49:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C3DF6B007B; Mon, 24 Apr 2023 01:49:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29B966B007D; Mon, 24 Apr 2023 01:49:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13B786B007E; Mon, 24 Apr 2023 01:49:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 028BA6B007B for ; Mon, 24 Apr 2023 01:49:54 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CAE68160129 for ; Mon, 24 Apr 2023 05:49:53 +0000 (UTC) X-FDA: 80715208266.02.4FF9A24 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf30.hostedemail.com (Postfix) with ESMTP id 12E5D8000D for ; Mon, 24 Apr 2023 05:49:51 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=IisOQjT9; spf=none (imf30.hostedemail.com: domain of BATV+e16e2fc4419b117693a1+7183+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+e16e2fc4419b117693a1+7183+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682315392; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TRgCZMat6SwmbUJc5nYBP6IbIwCnK37cme83Pl+2pA8=; b=YqJ7l5Lc5R0YggY1QSYRBB5RblDKBPvRjgCiR5IZYrZLsq5TB+S8goNxMHYkd4t2lkiB5n Vi0UCUT4cJTp9joRsbQMGn9GIy9586pxDnu8ugWXe9tkcq7BX7V+20efjq7zSVV6+13n4i +PJIp2B11/nwydWyUlZkgg1bDFGOsFA= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=IisOQjT9; spf=none (imf30.hostedemail.com: domain of BATV+e16e2fc4419b117693a1+7183+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+e16e2fc4419b117693a1+7183+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682315392; a=rsa-sha256; cv=none; b=Og88mdcnwotJNfY9ZDst9FmkEVwaCBiqoYAoahz9AU1Ue2yJOsFfv6I9P6DTj/EMiPkY1T aOTAcujIPKNMvBdr1ysBP/FAGLDLy92JTv6b89QdvdvBs6TWn8Rn8Ht2qqwfNv2yvNiBF/ WGRZItD7A6SpfKqzZ+2r/Qe6itgfydA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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=TRgCZMat6SwmbUJc5nYBP6IbIwCnK37cme83Pl+2pA8=; b=IisOQjT9f5WFKcdC3Jd5pbj8sh 4VxYG9fcjD21qV4vH246OoxCV6nph/mgCU3NIWP8P4y3dlViSSGAmZjXKbLou0yjIYZaM3cnIY2Kt mjxtvSSMGgpzOLyFt6Owfa5+glDjlrIybM/1ZBwz3b1jzQlJ1EgeUSLyfdrbYx4CDGDKxjiIrnu36 kfJfmV8CzCSfJEL70k1/Giql2X0o5GEh/voLjYWzXCdDVciAzPcCtw1ssj+JIttdkB/PCHceRsfbT 6ORot5jXqhFK8ewJjwizNl7JjjUwrZhWXmblesM672+/0ZZBeLqjjqHAXGNhN8Y39rALvBAMKA3jw wWfxZqbQ==; Received: from [2001:4bb8:189:a74f:e8a5:5f73:6d2:23b8] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pqp51-00FOul-1F; Mon, 24 Apr 2023 05:49:39 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Miklos Szeredi , "Darrick J. Wong" , Andrew Morton , David Howells , Matthew Wilcox , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, ceph-devel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/17] fs: rename and move block_page_mkwrite_return Date: Mon, 24 Apr 2023 07:49:12 +0200 Message-Id: <20230424054926.26927-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230424054926.26927-1-hch@lst.de> References: <20230424054926.26927-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 12E5D8000D X-Stat-Signature: hoxgz7aedmds14m6oepre8zkrxkntwut X-HE-Tag: 1682315391-762172 X-HE-Meta: U2FsdGVkX1+jzOo1RElDjBV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WwjJ75swWFaEAUW+KfM5A0+AqS6WFTceooQksJOEAH3p7/hCs4qiO6aVs8WDXUhqGJXP367lgmjU03uf8LF3UQ6fGZpuTMGviwvQZ7TYfYkoQRUhL56Ibqdq7Auz1YMVYaDJY/lJykqw/kKGSB4EUgSmtuq1RJyhJcE+NrQN1/D2T4fF9/E9iOmBFJFGA4vWhOYppcIAiK5XrW2wxMnw4X+Ken02PFCuXa0CmlHTks+Ln3VKKqIHjKEOTCCpmsKz1J86aYh9L6GDquRNuOGNT2gSnoRExjgfE2xtVuR4yTx032BE1p+U1XaMF6xNsAV+GUCL4yeWK/rhrL9taXBbabkJ4PI3GwwaF7O5wJ5WjYoEFq3S7MA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: block_page_mkwrite_return is neither block nor mkwrite specific, and should not be under CONFIG_BLOCK. Move it to mm.h and rename it to errno_to_vmfault. Signed-off-by: Christoph Hellwig --- fs/ext4/inode.c | 2 +- fs/f2fs/file.c | 2 +- fs/gfs2/file.c | 16 ++++++++-------- fs/iomap/buffered-io.c | 2 +- fs/nilfs2/file.c | 2 +- fs/udf/file.c | 2 +- include/linux/buffer_head.h | 12 ------------ include/linux/mm.h | 13 +++++++++++++ 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index bf0b7dea4900af..c0f41a38bd9ca4 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -6343,7 +6343,7 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) if (err == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) goto retry_alloc; out_ret: - ret = block_page_mkwrite_return(err); + ret = errno_to_vmfault(err); out: filemap_invalidate_unlock_shared(mapping); sb_end_pagefault(inode->i_sb); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 15dabeac469050..f4ab23efcf85f8 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -161,7 +161,7 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) sb_end_pagefault(inode->i_sb); err: - return block_page_mkwrite_return(err); + return errno_to_vmfault(err); } static const struct vm_operations_struct f2fs_file_vm_ops = { diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 300844f50dcd28..8c4fad359ff538 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -432,7 +432,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); err = gfs2_glock_nq(&gh); if (err) { - ret = block_page_mkwrite_return(err); + ret = errno_to_vmfault(err); goto out_uninit; } @@ -474,7 +474,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) err = gfs2_rindex_update(sdp); if (err) { - ret = block_page_mkwrite_return(err); + ret = errno_to_vmfault(err); goto out_unlock; } @@ -482,12 +482,12 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) ap.target = data_blocks + ind_blocks; err = gfs2_quota_lock_check(ip, &ap); if (err) { - ret = block_page_mkwrite_return(err); + ret = errno_to_vmfault(err); goto out_unlock; } err = gfs2_inplace_reserve(ip, &ap); if (err) { - ret = block_page_mkwrite_return(err); + ret = errno_to_vmfault(err); goto out_quota_unlock; } @@ -500,7 +500,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) } err = gfs2_trans_begin(sdp, rblocks, 0); if (err) { - ret = block_page_mkwrite_return(err); + ret = errno_to_vmfault(err); goto out_trans_fail; } @@ -508,7 +508,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) if (gfs2_is_stuffed(ip)) { err = gfs2_unstuff_dinode(ip); if (err) { - ret = block_page_mkwrite_return(err); + ret = errno_to_vmfault(err); goto out_trans_end; } } @@ -524,7 +524,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) err = gfs2_allocate_page_backing(page, length); if (err) - ret = block_page_mkwrite_return(err); + ret = errno_to_vmfault(err); out_page_locked: if (ret != VM_FAULT_LOCKED) @@ -558,7 +558,7 @@ static vm_fault_t gfs2_fault(struct vm_fault *vmf) gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &gh); err = gfs2_glock_nq(&gh); if (err) { - ret = block_page_mkwrite_return(err); + ret = errno_to_vmfault(err); goto out_uninit; } ret = filemap_fault(vmf); diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 6f4c97a6d7e9dc..2986be63d2bea6 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1290,7 +1290,7 @@ vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops) return VM_FAULT_LOCKED; out_unlock: folio_unlock(folio); - return block_page_mkwrite_return(ret); + return errno_to_vmfault(ret); } EXPORT_SYMBOL_GPL(iomap_page_mkwrite); diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index a265d391ffe92d..ea35294bb158a3 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -108,7 +108,7 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) wait_for_stable_page(page); out: sb_end_pagefault(inode->i_sb); - return block_page_mkwrite_return(ret); + return errno_to_vmfault(ret); } static const struct vm_operations_struct nilfs_file_vm_ops = { diff --git a/fs/udf/file.c b/fs/udf/file.c index 8238f742377bab..9420284d7c0455 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -71,7 +71,7 @@ static vm_fault_t udf_page_mkwrite(struct vm_fault *vmf) err = block_commit_write(page, 0, end); if (err < 0) { unlock_page(page); - ret = block_page_mkwrite_return(err); + ret = errno_to_vmfault(err); goto out_unlock; } out_dirty: diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 8f14dca5fed756..0fcc16b7f02bb4 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -281,18 +281,6 @@ int generic_cont_expand_simple(struct inode *inode, loff_t size); int block_commit_write(struct page *page, unsigned from, unsigned to); int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, get_block_t get_block); -/* Convert errno to return value from ->page_mkwrite() call */ -static inline vm_fault_t block_page_mkwrite_return(int err) -{ - if (err == 0) - return VM_FAULT_LOCKED; - if (err == -EFAULT || err == -EAGAIN) - return VM_FAULT_NOPAGE; - if (err == -ENOMEM) - return VM_FAULT_OOM; - /* -ENOSPC, -EDQUOT, -EIO ... */ - return VM_FAULT_SIGBUS; -} sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *); int block_truncate_page(struct address_space *, loff_t, get_block_t *); diff --git a/include/linux/mm.h b/include/linux/mm.h index 1f79667824eb60..03e645032c81ac 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3061,6 +3061,19 @@ extern vm_fault_t filemap_map_pages(struct vm_fault *vmf, pgoff_t start_pgoff, pgoff_t end_pgoff); extern vm_fault_t filemap_page_mkwrite(struct vm_fault *vmf); +/* Convert errno to return value from ->page_mkwrite() call */ +static inline vm_fault_t errno_to_vmfault(int err) +{ + if (err == 0) + return VM_FAULT_LOCKED; + if (err == -EFAULT || err == -EAGAIN) + return VM_FAULT_NOPAGE; + if (err == -ENOMEM) + return VM_FAULT_OOM; + /* -ENOSPC, -EDQUOT, -EIO ... */ + return VM_FAULT_SIGBUS; +} + extern unsigned long stack_guard_gap; /* Generic expand stack which grows the stack according to GROWS{UP,DOWN} */ extern int expand_stack(struct vm_area_struct *vma, unsigned long address);