From patchwork Wed Jan 25 09:41:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115346 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7834C54EED for ; Wed, 25 Jan 2023 09:42:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234996AbjAYJmE (ORCPT ); Wed, 25 Jan 2023 04:42:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234955AbjAYJmC (ORCPT ); Wed, 25 Jan 2023 04:42:02 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75E0B9005 for ; Wed, 25 Jan 2023 01:42:01 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3096B1FED0; Wed, 25 Jan 2023 09:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639720; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oMSzfWfD7/SM2a3hJykihl68Hqs5dpEiEJt6FdJqpvE=; b=pxtUYyuamtobe0tFIfcehsfR+ns78OnGxB0XZr3CfYkkB/o8SNK8blf5vipfui5TSIHTxV 2lqZZpfPB9DbboM3KkQ9kzhtJVvoyHSbja6oC8STdm7Kj9F8fP4m7Uu7SbBTRd99JTlE6i a91V1Rb2Zy6iqg3hQ4RJaWgV1dK7vQ4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639720; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oMSzfWfD7/SM2a3hJykihl68Hqs5dpEiEJt6FdJqpvE=; b=tsVcOEFlOq0hW6ITtCHKIbhklu4amTQJVLJvaDRAyhhao/DAYFy3KcQzkFp5BqZaL5mqr3 WGEY6PihL4Tpy0Dw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1B34213A08; Wed, 25 Jan 2023 09:42:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ll6bBmj50GMUIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:00 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 3D901A06B6; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara , Christoph Hellwig Subject: [PATCH v2 01/12] udf: Unify .read_folio for normal and in-ICB files Date: Wed, 25 Jan 2023 10:41:43 +0100 Message-Id: <20230125094159.10877-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3573; i=jack@suse.cz; h=from:subject; bh=nYpSEcS0ug2d1fCKnNAsHlaBxvR6MQHkIOos6izMw9M=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0PlXPIoktWeUHiZ1qLOzPoQfoBs5NyOxTWc5A38m 0ZVJeyqJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5VwAKCRCcnaoHP2RA2cHsCA CBLTMLg0d7whkELxRICHQI+dzIv7ztB3MbRs8UiG7Z6NX19bim4AUv+5vwJ3l1xiqn3FRp519mVFhh Fe2o6+7CubE36wsz81emJGCwH3H681d3zfRLdCW40c8vEyx5hELiPQvdbwY6rLmb8Qp4oZjBNku70z SPshtViifepG4/gYRRFIQFfs4K8xPJfTHcFZgQ4HekplRN0IpCtG7ogMeVyZ4caKiloAw7xPpKARot u/JPoJrG2nFzlc+5x+SP1/nrBOhLA5MTsol3IxGXiSD6+FKtfGloZPqvFX6ngrdBdPFLRF/UNsq4wS txB8xRWLd3iyNQDqvEb5ZSQbAhAjg6 X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Switching address_space_operations while a file is used is difficult to do in a race-free way. To be able to use single address_space_operations in UDF, make udf_read_folio() handle both normal and in-ICB files. Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/udf/file.c | 15 +++------------ fs/udf/inode.c | 9 ++++++++- fs/udf/udfdecl.h | 2 ++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/udf/file.c b/fs/udf/file.c index 322115c8369d..2666234a5204 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -38,7 +38,7 @@ #include "udf_i.h" #include "udf_sb.h" -static void __udf_adinicb_readpage(struct page *page) +void udf_adinicb_readpage(struct page *page) { struct inode *inode = page->mapping->host; char *kaddr; @@ -57,15 +57,6 @@ static void __udf_adinicb_readpage(struct page *page) kunmap_atomic(kaddr); } -static int udf_adinicb_read_folio(struct file *file, struct folio *folio) -{ - BUG_ON(!folio_test_locked(folio)); - __udf_adinicb_readpage(&folio->page); - folio_unlock(folio); - - return 0; -} - static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc) { @@ -100,7 +91,7 @@ static int udf_adinicb_write_begin(struct file *file, *pagep = page; if (!PageUptodate(page)) - __udf_adinicb_readpage(page); + udf_adinicb_readpage(page); return 0; } @@ -127,7 +118,7 @@ static int udf_adinicb_write_end(struct file *file, struct address_space *mappin const struct address_space_operations udf_adinicb_aops = { .dirty_folio = block_dirty_folio, .invalidate_folio = block_invalidate_folio, - .read_folio = udf_adinicb_read_folio, + .read_folio = udf_read_folio, .writepage = udf_adinicb_writepage, .write_begin = udf_adinicb_write_begin, .write_end = udf_adinicb_write_end, diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 8b73515227ff..b90b9862b073 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -191,8 +191,15 @@ static int udf_writepages(struct address_space *mapping, return mpage_writepages(mapping, wbc, udf_get_block_wb); } -static int udf_read_folio(struct file *file, struct folio *folio) +int udf_read_folio(struct file *file, struct folio *folio) { + struct udf_inode_info *iinfo = UDF_I(file_inode(file)); + + if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { + udf_adinicb_readpage(&folio->page); + folio_unlock(folio); + return 0; + } return mpage_read_folio(folio, udf_get_block); } diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index 5ba59ab90d48..6b93b393cb46 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -138,6 +138,7 @@ static inline unsigned int udf_dir_entry_len(struct fileIdentDesc *cfi) /* file.c */ extern long udf_ioctl(struct file *, unsigned int, unsigned long); +void udf_adinicb_readpage(struct page *page); /* inode.c */ extern struct inode *__udf_iget(struct super_block *, struct kernel_lb_addr *, @@ -158,6 +159,7 @@ extern struct buffer_head *udf_bread(struct inode *inode, udf_pblk_t block, extern int udf_setsize(struct inode *, loff_t); extern void udf_evict_inode(struct inode *); extern int udf_write_inode(struct inode *, struct writeback_control *wbc); +int udf_read_folio(struct file *file, struct folio *folio); extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *, struct kernel_lb_addr *, uint32_t *, sector_t *); int udf_get_block(struct inode *, sector_t, struct buffer_head *, int); From patchwork Wed Jan 25 09:41:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115347 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC36BC54E94 for ; Wed, 25 Jan 2023 09:42:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235089AbjAYJmE (ORCPT ); Wed, 25 Jan 2023 04:42:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234783AbjAYJmC (ORCPT ); Wed, 25 Jan 2023 04:42:02 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75AEA869F for ; Wed, 25 Jan 2023 01:42:01 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3128A21C80; Wed, 25 Jan 2023 09:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639720; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Dte/4yhsHWpU9dGZkfSaM4oLYxYY4PCuzaDdP5EdEQ=; b=Yo43GBaIl5Dgf38qD+QYetIW40POSRXAL4DhcK6Yf1aL47QGMfaW83p6guFaYramHkZEws a8HL4vlhnUG8hp5ckO0CGhvC4shoACgeEZrVIcifF1wVcgC1Ng4y861quxl5U0xWmA4/ww o3hHhpCD5VswiK1LmE6iafSC2C09xuk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639720; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Dte/4yhsHWpU9dGZkfSaM4oLYxYY4PCuzaDdP5EdEQ=; b=R5WS7jA2NOIFIYRz28B3fTrCXhZt3a7USsDb3fCE6INrfFgas7VV4o7hVC6AwDso1q4eXL 7JSPAsWYOwXlMFCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 17C5F13A06; Wed, 25 Jan 2023 09:42:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id u7sSBWj50GMSIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:00 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 43F6FA06B9; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara , syzbot+c27475eb921c46bbdc62@syzkaller.appspotmail.com, Christoph Hellwig Subject: [PATCH v2 02/12] udf: Convert in-ICB files to use udf_writepages() Date: Wed, 25 Jan 2023 10:41:44 +0100 Message-Id: <20230125094159.10877-2-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3814; i=jack@suse.cz; h=from:subject; bh=lpY+jaVzKgwDvo4FoC8bkZv2ZnGGLKYrbXTovEH8ekQ=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0PlY8EbfNO2kx0Q+K82hC/HU6lelpYnCAPbIoM5e AXSrNXyJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5WAAKCRCcnaoHP2RA2aN3CA CyQKHdLFvYrkgqAJIXCy7Sn97+tiu8MoYQY+jawdD1sn4rKQE0aFLx1+KXtQIvAFg0jCRULK8RspXg xMuFXVayk8TWvM2QZWGcpZqWMQ63hQwxr36FDRLmiKe7tz+brlm+baKTb2/e7nNG3PnlATJCZWBpwu 0DTqsuSie0QZWhSlPZlBJ7g2X4vbhT6/SFsY3egojHbTcP4LHHdmhNR5BGaOdvysnlsmHjJYdxd0qV x7X4+aJcSh4Gp1pvjGW1ZtBoTl6y+4W7FHQ7yHGbS3WGUxvD5j8qdXDKoFrHSwAFoUkJRRM73Rp7LD mMT5RcqbP58Ivj0zz0aXtaKJeog1TI X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Switching address_space_operations while a file is used is difficult to do in a race-free way. To be able to use single address_space_operations in UDF, make in-ICB files use udf_writepages(). Reported-by: syzbot+c27475eb921c46bbdc62@syzkaller.appspotmail.com Reported-by: Christoph Hellwig Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/udf/file.c | 21 +-------------------- fs/udf/inode.c | 29 ++++++++++++++++++++++++++--- fs/udf/udfdecl.h | 1 + 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/fs/udf/file.c b/fs/udf/file.c index 2666234a5204..7a8dbad86e41 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -57,25 +57,6 @@ void udf_adinicb_readpage(struct page *page) kunmap_atomic(kaddr); } -static int udf_adinicb_writepage(struct page *page, - struct writeback_control *wbc) -{ - struct inode *inode = page->mapping->host; - char *kaddr; - struct udf_inode_info *iinfo = UDF_I(inode); - - BUG_ON(!PageLocked(page)); - - kaddr = kmap_atomic(page); - memcpy(iinfo->i_data + iinfo->i_lenEAttr, kaddr, i_size_read(inode)); - SetPageUptodate(page); - kunmap_atomic(kaddr); - mark_inode_dirty(inode); - unlock_page(page); - - return 0; -} - static int udf_adinicb_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, struct page **pagep, @@ -119,7 +100,7 @@ const struct address_space_operations udf_adinicb_aops = { .dirty_folio = block_dirty_folio, .invalidate_folio = block_invalidate_folio, .read_folio = udf_read_folio, - .writepage = udf_adinicb_writepage, + .writepages = udf_writepages, .write_begin = udf_adinicb_write_begin, .write_end = udf_adinicb_write_end, .direct_IO = udf_adinicb_direct_IO, diff --git a/fs/udf/inode.c b/fs/udf/inode.c index b90b9862b073..3c6a129d1ae9 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -185,10 +185,33 @@ static void udf_write_failed(struct address_space *mapping, loff_t to) } } -static int udf_writepages(struct address_space *mapping, - struct writeback_control *wbc) +static int udf_adinicb_writepage(struct page *page, + struct writeback_control *wbc, void *data) { - return mpage_writepages(mapping, wbc, udf_get_block_wb); + struct inode *inode = page->mapping->host; + char *kaddr; + struct udf_inode_info *iinfo = UDF_I(inode); + + BUG_ON(!PageLocked(page)); + + kaddr = kmap_atomic(page); + memcpy(iinfo->i_data + iinfo->i_lenEAttr, kaddr, i_size_read(inode)); + SetPageUptodate(page); + kunmap_atomic(kaddr); + unlock_page(page); + mark_inode_dirty(inode); + + return 0; +} + +int udf_writepages(struct address_space *mapping, struct writeback_control *wbc) +{ + struct inode *inode = mapping->host; + struct udf_inode_info *iinfo = UDF_I(inode); + + if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) + return mpage_writepages(mapping, wbc, udf_get_block_wb); + return write_cache_pages(mapping, wbc, udf_adinicb_writepage, NULL); } int udf_read_folio(struct file *file, struct folio *folio) diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index 6b93b393cb46..48647eab26a6 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -160,6 +160,7 @@ extern int udf_setsize(struct inode *, loff_t); extern void udf_evict_inode(struct inode *); extern int udf_write_inode(struct inode *, struct writeback_control *wbc); int udf_read_folio(struct file *file, struct folio *folio); +int udf_writepages(struct address_space *mapping, struct writeback_control *wbc); extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *, struct kernel_lb_addr *, uint32_t *, sector_t *); int udf_get_block(struct inode *, sector_t, struct buffer_head *, int); From patchwork Wed Jan 25 09:41:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115351 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B21FBC27C76 for ; Wed, 25 Jan 2023 09:42:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235222AbjAYJmK (ORCPT ); Wed, 25 Jan 2023 04:42:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235009AbjAYJmD (ORCPT ); Wed, 25 Jan 2023 04:42:03 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DAC030DF for ; Wed, 25 Jan 2023 01:42:01 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1F09B21C7D; Wed, 25 Jan 2023 09:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639720; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tbMzmf9G8WMjoORBLmai2ybFW7arGcn8bzeTN+8RUx8=; b=KbhqZZW5csiAwnxnkrFuvwIcnieHOH6OLHxw2QW41Yi+DH15nr9KMbmKhFCLp76DQnCByM Mkh1Ast2vk0RmMuNcGVSkiyd7tqwiZhPPFnEuR60vYXNKT0hiwIZnWwXUmTWHyzslO3ECw 1o8ZsisP+sDMq2TPGpYmCqdU29LzcjA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639720; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tbMzmf9G8WMjoORBLmai2ybFW7arGcn8bzeTN+8RUx8=; b=EJ4fG5wj8K1r9pYubWTKSwz88HYWgzSpSPxNZ3cSewUmLXo/KcL5j61NRjNL/XIpDSip+0 GKn2kn5G5kphcoCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 05FED1358F; Wed, 25 Jan 2023 09:42:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0KttAWj50GMNIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:00 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 4A11EA06C5; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara , Christoph Hellwig Subject: [PATCH v2 03/12] udf: Convert in-ICB files to use udf_direct_IO() Date: Wed, 25 Jan 2023 10:41:45 +0100 Message-Id: <20230125094159.10877-3-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2946; i=jack@suse.cz; h=from:subject; bh=OpupSpv5nOqZ+Mai/BiVUoRv28As2Dk8TvM4mIs7FIQ=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0PlZLGiELpNTMVeLOuGBK2HrAXX+zSb6DilH3NZ8 BjscdTuJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5WQAKCRCcnaoHP2RA2YqoB/ 9IgLA2d1exN5GkJHRSqI2mEIQsnspFPdYcUWBLh2ylpqh0Sw7YlU4OT1HlymcCgr87DR825+drj/Do FLdEbjeycpWi+8savvAhXGHmaeqRkjEbcKVBDqzq9VqF+CAZLgB4FAiDYdVEGvXe1yrV9l+rnUM1Pl z6729RynT3gk4DdMvqE7xFmYAdV2JD6A4W2Lk3aCxyf1q6N4UlQVqVfafI/1b/+usuFUYpi10g2YEu cOdo8Nppet18a1STZiuKOVTaULgomXydn+GHl3k9qdUvAk7EpG7ztHBnnWKbsjZY58ONi1cSosoloj QhbOC+XXghA0yWkJop3A+wz5Lw5lEJ X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Switching address_space_operations while a file is used is difficult to do in a race-free way. To be able to use single address_space_operations in UDF, make in-ICB files use udf_direct_IO(). Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/udf/file.c | 8 +------- fs/udf/inode.c | 5 ++++- fs/udf/udfdecl.h | 1 + 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/fs/udf/file.c b/fs/udf/file.c index 7a8dbad86e41..6bab6aa7770a 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -76,12 +76,6 @@ static int udf_adinicb_write_begin(struct file *file, return 0; } -static ssize_t udf_adinicb_direct_IO(struct kiocb *iocb, struct iov_iter *iter) -{ - /* Fallback to buffered I/O. */ - return 0; -} - static int udf_adinicb_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, struct page *page, void *fsdata) @@ -103,7 +97,7 @@ const struct address_space_operations udf_adinicb_aops = { .writepages = udf_writepages, .write_begin = udf_adinicb_write_begin, .write_end = udf_adinicb_write_end, - .direct_IO = udf_adinicb_direct_IO, + .direct_IO = udf_direct_IO, }; static vm_fault_t udf_page_mkwrite(struct vm_fault *vmf) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 3c6a129d1ae9..dafbc99b78a3 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -243,7 +243,7 @@ static int udf_write_begin(struct file *file, struct address_space *mapping, return ret; } -static ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter) +ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter) { struct file *file = iocb->ki_filp; struct address_space *mapping = file->f_mapping; @@ -251,6 +251,9 @@ static ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter) size_t count = iov_iter_count(iter); ssize_t ret; + /* Fallback to buffered IO for in-ICB files */ + if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) + return 0; ret = blockdev_direct_IO(iocb, inode, iter, udf_get_block); if (unlikely(ret < 0 && iov_iter_rw(iter) == WRITE)) udf_write_failed(mapping, iocb->ki_pos + count); diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index 48647eab26a6..a851613465c6 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -161,6 +161,7 @@ extern void udf_evict_inode(struct inode *); extern int udf_write_inode(struct inode *, struct writeback_control *wbc); int udf_read_folio(struct file *file, struct folio *folio); int udf_writepages(struct address_space *mapping, struct writeback_control *wbc); +ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter); extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *, struct kernel_lb_addr *, uint32_t *, sector_t *); int udf_get_block(struct inode *, sector_t, struct buffer_head *, int); From patchwork Wed Jan 25 09:41:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115350 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3218C54EED for ; Wed, 25 Jan 2023 09:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235213AbjAYJmJ (ORCPT ); Wed, 25 Jan 2023 04:42:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235016AbjAYJmD (ORCPT ); Wed, 25 Jan 2023 04:42:03 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8014A2B29F for ; Wed, 25 Jan 2023 01:42:01 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 38C2421C82; Wed, 25 Jan 2023 09:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639720; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bTexrFokGErC1DDMr8ao4jUpUNu1UsdaZ82C7rmjD58=; b=puwUbTe87RttOHWh+5ArPV5/RqAaqJYWkkahjlp4GjC2V/nmg9xzuou21mpEMONXdqxL30 Osxi5FRdTI1UjPs89JObnrEPjU/Bm4cpT+Tx0028qC5GrN0Lo0ig9votKLg/55z7aBgoab vAug5Tp/7KF5qA573yDccCzqLpoqYKk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639720; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bTexrFokGErC1DDMr8ao4jUpUNu1UsdaZ82C7rmjD58=; b=b+btVccKW12trPBN8ezNGT6i+U0PjlATRDRq3Tx/6e3mmMS6I5VCh0BdC/yCdF0mHVif2R sSb7cTtPNXCXyaAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2967F13A09; Wed, 25 Jan 2023 09:42:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id BKEHCWj50GMWIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:00 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 5060EA06C6; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara , Christoph Hellwig Subject: [PATCH v2 04/12] udf: Convert in-ICB files to use udf_write_begin() Date: Wed, 25 Jan 2023 10:41:46 +0100 Message-Id: <20230125094159.10877-4-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3688; i=jack@suse.cz; h=from:subject; bh=Q35WItHGUnCNRlRjCs8qc4xP7+XrQgyl03pCdYb76xU=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0PlalD8FlrflI4tRJ6J9e8TxzGp36FO0Am4IDUt5 VkEPiZGJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5WgAKCRCcnaoHP2RA2bY0CA DuCjhkgosDftPsH81fNQE9QqDHHhp2rhd547gNmpzwKeXT0gvBb2p3Gj75mucVH1L3sY+3V3MUh41D qAIoU0hj2KwA9yREETzo3exK7oVnGpR90hgxrcui360A0ox37ej+SUz1ZPVc4jT2UFUrk9IOPBuqU/ c3Ck7D7KYHlDYWjVu57SWW5wMugSSFLKgS03Gs2uK748w4z5ErbmvKYj+oFfv4bXBrZbnvDXVbC1UI 8tx0Ebzi382dxp1qQ7JEJTN9y/bFtu1M7Hcov1om0QEGK1CPpIE1Yp00hg5vQFHSUvPyk22vgcNxH9 yuIxT+bKMQfAN++H84bILte2+mMzk1 X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Switching address_space_operations while a file is used is difficult to do in a race-free way. To be able to use single address_space_operations in UDF, make in-ICB files use udf_write_begin(). Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/udf/file.c | 21 +-------------------- fs/udf/inode.c | 24 +++++++++++++++++++----- fs/udf/udfdecl.h | 3 +++ 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/fs/udf/file.c b/fs/udf/file.c index 6bab6aa7770a..16aecf4b2387 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -57,25 +57,6 @@ void udf_adinicb_readpage(struct page *page) kunmap_atomic(kaddr); } -static int udf_adinicb_write_begin(struct file *file, - struct address_space *mapping, loff_t pos, - unsigned len, struct page **pagep, - void **fsdata) -{ - struct page *page; - - if (WARN_ON_ONCE(pos >= PAGE_SIZE)) - return -EIO; - page = grab_cache_page_write_begin(mapping, 0); - if (!page) - return -ENOMEM; - *pagep = page; - - if (!PageUptodate(page)) - udf_adinicb_readpage(page); - return 0; -} - static int udf_adinicb_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, struct page *page, void *fsdata) @@ -95,7 +76,7 @@ const struct address_space_operations udf_adinicb_aops = { .invalidate_folio = block_invalidate_folio, .read_folio = udf_read_folio, .writepages = udf_writepages, - .write_begin = udf_adinicb_write_begin, + .write_begin = udf_write_begin, .write_end = udf_adinicb_write_end, .direct_IO = udf_direct_IO, }; diff --git a/fs/udf/inode.c b/fs/udf/inode.c index dafbc99b78a3..c165dd9714b9 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -231,16 +231,30 @@ static void udf_readahead(struct readahead_control *rac) mpage_readahead(rac, udf_get_block); } -static int udf_write_begin(struct file *file, struct address_space *mapping, +int udf_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, struct page **pagep, void **fsdata) { + struct udf_inode_info *iinfo = UDF_I(file_inode(file)); + struct page *page; int ret; - ret = block_write_begin(mapping, pos, len, pagep, udf_get_block); - if (unlikely(ret)) - udf_write_failed(mapping, pos + len); - return ret; + if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { + ret = block_write_begin(mapping, pos, len, pagep, + udf_get_block); + if (unlikely(ret)) + udf_write_failed(mapping, pos + len); + return ret; + } + if (WARN_ON_ONCE(pos >= PAGE_SIZE)) + return -EIO; + page = grab_cache_page_write_begin(mapping, 0); + if (!page) + return -ENOMEM; + *pagep = page; + if (!PageUptodate(page)) + udf_adinicb_readpage(page); + return 0; } ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter) diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index a851613465c6..32decf6b6a21 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -161,6 +161,9 @@ extern void udf_evict_inode(struct inode *); extern int udf_write_inode(struct inode *, struct writeback_control *wbc); int udf_read_folio(struct file *file, struct folio *folio); int udf_writepages(struct address_space *mapping, struct writeback_control *wbc); +int udf_write_begin(struct file *file, struct address_space *mapping, + loff_t pos, unsigned len, + struct page **pagep, void **fsdata); ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter); extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *, struct kernel_lb_addr *, uint32_t *, sector_t *); From patchwork Wed Jan 25 09:41:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115357 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2A51C61D9D for ; Wed, 25 Jan 2023 09:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235221AbjAYJmR (ORCPT ); Wed, 25 Jan 2023 04:42:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234783AbjAYJmF (ORCPT ); Wed, 25 Jan 2023 04:42:05 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F399930DF for ; Wed, 25 Jan 2023 01:42:03 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2C30E21C74; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wFsroFWVQ9Mnyo2w/YZq8LcTL1TArB27vUMXBp9llxE=; b=iTgvfZJuIiocP361KZiLKGvexIG0P/JOYexxyP17JcCpxjrcUS+2JxvibvQOCSFk8CWlPE PaP4kAJndPnGrBA7eY1tsFB4ENirP1gBe1t7GubnDF8QerEsfMCTjCBDaG4HMsYygLUwOi 2+fbfabUVT5xeT/72hsE6rNVKotZQqI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wFsroFWVQ9Mnyo2w/YZq8LcTL1TArB27vUMXBp9llxE=; b=M6TVGW7au1jYhh2KTk4rVnxruTWxp+TXWiRjGcYXVnhM/mnf4687C4pTjUjBLcHD2nsDdu ATy9rfzjQ1gD0+CA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0622E1358F; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IVSWAWn50GMkIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:01 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 55320A06D0; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara , Christoph Hellwig Subject: [PATCH v2 05/12] udf: Convert all file types to use udf_write_end() Date: Wed, 25 Jan 2023 10:41:47 +0100 Message-Id: <20230125094159.10877-5-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3512; i=jack@suse.cz; h=from:subject; bh=d88CriuKCFiUkVD3qyJkIo32zhq3lnVoaV6ED6xbV9E=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0PlbSC3ltAvMwQwcPcR5MWAcv6wqCQMp8N75Wve/ fK21E+eJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5WwAKCRCcnaoHP2RA2a7RB/ 9AYYFirFwvanGXSwqjZSLf7Wb+oMcdlkYohD6EOcteQP5PU2A7yCbN2mFUxBKtETYcHeGu15bsOUEf Rs0fEARhC/YfyzpPDlmhWY4uK/T/N5vI4OLiQBifNeKrTS1bWSjH3jw0LNfR8YRpD9U1YY01IYzcav yfBsU3o5vecQTYt/ZbE2REMa7QWCEexdLqcn4Sz3f9SDrZsp8p9c9JUyUuExZyD8dF4j52K/Scs0tZ /lL8iASK70jySfHSX4om6Y8topDR3XFF5dazhPjS1OKIqYA8FL4OD2YM+7CAwQqRbeHISCksYxTGlI ERVWlvQQ1gd9xymjp5PxdnQqxFOb7B X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Switching address_space_operations while a file is used is difficult to do in a race-free way. To be able to use single address_space_operations in UDF, create udf_write_end() function that is able to handle both normal and in-ICB files. Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/udf/file.c | 16 +--------------- fs/udf/inode.c | 22 +++++++++++++++++++++- fs/udf/udfdecl.h | 3 +++ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/fs/udf/file.c b/fs/udf/file.c index 16aecf4b2387..8a37cd593883 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -57,27 +57,13 @@ void udf_adinicb_readpage(struct page *page) kunmap_atomic(kaddr); } -static int udf_adinicb_write_end(struct file *file, struct address_space *mapping, - loff_t pos, unsigned len, unsigned copied, - struct page *page, void *fsdata) -{ - struct inode *inode = page->mapping->host; - loff_t last_pos = pos + copied; - if (last_pos > inode->i_size) - i_size_write(inode, last_pos); - set_page_dirty(page); - unlock_page(page); - put_page(page); - return copied; -} - const struct address_space_operations udf_adinicb_aops = { .dirty_folio = block_dirty_folio, .invalidate_folio = block_invalidate_folio, .read_folio = udf_read_folio, .writepages = udf_writepages, .write_begin = udf_write_begin, - .write_end = udf_adinicb_write_end, + .write_end = udf_write_end, .direct_IO = udf_direct_IO, }; diff --git a/fs/udf/inode.c b/fs/udf/inode.c index c165dd9714b9..ac00f2f5dbe3 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -257,6 +257,26 @@ int udf_write_begin(struct file *file, struct address_space *mapping, return 0; } +int udf_write_end(struct file *file, struct address_space *mapping, + loff_t pos, unsigned len, unsigned copied, + struct page *page, void *fsdata) +{ + struct inode *inode = file_inode(file); + loff_t last_pos; + + if (UDF_I(inode)->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) + return generic_write_end(file, mapping, pos, len, copied, page, + fsdata); + last_pos = pos + copied; + if (last_pos > inode->i_size) + i_size_write(inode, last_pos); + set_page_dirty(page); + unlock_page(page); + put_page(page); + + return copied; +} + ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter) { struct file *file = iocb->ki_filp; @@ -286,7 +306,7 @@ const struct address_space_operations udf_aops = { .readahead = udf_readahead, .writepages = udf_writepages, .write_begin = udf_write_begin, - .write_end = generic_write_end, + .write_end = udf_write_end, .direct_IO = udf_direct_IO, .bmap = udf_bmap, .migrate_folio = buffer_migrate_folio, diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index 32decf6b6a21..304c2ec81589 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -164,6 +164,9 @@ int udf_writepages(struct address_space *mapping, struct writeback_control *wbc) int udf_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, struct page **pagep, void **fsdata); +int udf_write_end(struct file *file, struct address_space *mapping, + loff_t pos, unsigned len, unsigned copied, + struct page *page, void *fsdata); ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter); extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *, struct kernel_lb_addr *, uint32_t *, sector_t *); From patchwork Wed Jan 25 09:41:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115349 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6862CC27C76 for ; Wed, 25 Jan 2023 09:42:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235203AbjAYJmH (ORCPT ); Wed, 25 Jan 2023 04:42:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235003AbjAYJmD (ORCPT ); Wed, 25 Jan 2023 04:42:03 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CEE22716 for ; Wed, 25 Jan 2023 01:42:02 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2C69A21C75; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fKZCg56SLXKhpJFJJrYRNWhwGQPw+NL+HfCTPmmGANk=; b=c+OtSO9IQIAjwaM7ZiF+Ed6xzjnN9Wlyk9bzTwXqK6cJoOkvB/GuMc+3ilHKsOEkeUhQF5 LzWea5OnDP9ZRIZd3yjCqyWO/UZVkx8FMIyJhaw5J1MUKwVwnj2R7a1Lpo7lQUl+Nrqo8j w65BtowmDuTXsPz4AmQXXgEdHaU0QKU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fKZCg56SLXKhpJFJJrYRNWhwGQPw+NL+HfCTPmmGANk=; b=ZezVwK2EmUFVVsFDS3MJ/sO+hGZJFwzIMtsurWWI9119rpYQBNJUfhOO8ePltcSD5sJIi5 jqgwJDT/Lrt0mbAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0629D13A06; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qGl8AWn50GMjIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:01 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 5B35AA06D1; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara , Christoph Hellwig Subject: [PATCH v2 06/12] udf: Add handling of in-ICB files to udf_bmap() Date: Wed, 25 Jan 2023 10:41:48 +0100 Message-Id: <20230125094159.10877-6-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=808; i=jack@suse.cz; h=from:subject; bh=SG93GLCqJUSys5SPhE0AZ913xuFOg4SurHldDmQy7kk=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0PlcWCIq7YQTR1W8KTJ12QvKCanYkbMoBf/mYakQ ze23vhGJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5XAAKCRCcnaoHP2RA2duqCA CnS2iKLUMbHEUlZSx2Ud0wEJ3E6NHilOytX7w6I5HAbb4oiD9M7h4sDK75boRbCxKXBCkgQhztAZKj 6Jd8PU0hEAnakfyyxDSLHOic7IRnsgrWlSKjiSp0hMj04kq9HbrONKXn8UfkSYfEWEqLOUTfIXZR8a Y7O3ZSfb7kdzFL63e8HHEeX2Jn6ZmwhEdjvrGJLX82Ci9Q+5C2jOgSXD8lpHmAKfE092mH79SrtB5A XEeuBVYoX3rrRsLju1xrUaqrv9DZnZkb+zU4va2XF3Issy18OdRUxnUQsg+dQOpn3/dLe9UqnDbXTV mGHgQorrtsWtphnWI73GX+WtGuk26t X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add detection of in-ICB files to udf_bmap() and return error in that case. This will allow us o use single address_space_operations in UDF. Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/udf/inode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index ac00f2f5dbe3..08788f4dab18 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -296,6 +296,10 @@ ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter) static sector_t udf_bmap(struct address_space *mapping, sector_t block) { + struct udf_inode_info *iinfo = UDF_I(mapping->host); + + if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) + return -EINVAL; return generic_block_bmap(mapping, block, udf_get_block); } From patchwork Wed Jan 25 09:41:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115352 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCE7FC54E94 for ; Wed, 25 Jan 2023 09:42:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235260AbjAYJmL (ORCPT ); Wed, 25 Jan 2023 04:42:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235065AbjAYJmE (ORCPT ); Wed, 25 Jan 2023 04:42:04 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA6333E605 for ; Wed, 25 Jan 2023 01:42:02 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 66A221FED3; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RNDeGcAcNfWovMkLBflrnWlvuVPSGK3tbme67GuWFI8=; b=Yqbclam4UJlZJEKQetArLrzI2rGtV+omyMhbrhJRq/8OYCDWG5u6oxqTnOawLdcSP9NvCp m1B4VWepC9Tqu2/3eVLwufPC94+izK/Dk9bgCmKEpVaQ0PB1rXMfd+tBf8clUE3D6sUTnO eHHO6zIHCdw/Yt0WxEw/ltIMbU8ND1w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RNDeGcAcNfWovMkLBflrnWlvuVPSGK3tbme67GuWFI8=; b=RiwLxN2VBe91zHzO0uIPjj6qSTMSUqzrgOBkmdcJrm4QIpQpnBRVlNmddpEr0R7VWXdn5D /9u05w6fJRL9IRDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4E18A13A09; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ZRP2Emn50GMrIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:01 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 618E7A06D3; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara , Christoph Hellwig Subject: [PATCH v2 07/12] udf: Switch to single address_space_operations Date: Wed, 25 Jan 2023 10:41:49 +0100 Message-Id: <20230125094159.10877-7-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3890; i=jack@suse.cz; h=from:subject; bh=Ic4KPsvy5xba38AVKbVRi9vSjqbXzfOGFdLBTYgplto=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0PldpBfvAPyJJ38WXkAFN4/ZDhK6FrtIMF146H6d hTgv/zWJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5XQAKCRCcnaoHP2RA2UECB/ 42ss2M6Q5gyHzTlxX0bMjbYaow7qmaD2+NasSC/GHmFJX77F/qtBi+/sCUybO6dTcYL7q4mOQEQHcV AEbY+bmly/F5hMdOKA4a6HYNdgvMbpTCPzV2xO0W8oPhpULY2liVsbyefiggUAHDHUxt3z09iHyUdA G6ZNMO9Eu5ogE3zF4Qa9+yAQ2qNPAQUe8L3AMn0Tt22IzHATtsCijSUvYBm7HAZRb8g4BBBYNnw44q ZCEohrcPEzfPzAHePlJFC+cLJfWu6lqqzJZSLkYWnXUO9qMeU0VybSt8JIcjeS4en8GGSlOWo41w6u NqknmISbmEz52xingkrEQVnvn2HMbc X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Now that udf_aops and udf_adiniicb_aops are functionally identical, just drop udf_adiniicb_aops. Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/udf/file.c | 10 ---------- fs/udf/inode.c | 8 +------- fs/udf/namei.c | 10 ++-------- fs/udf/udfdecl.h | 1 - 4 files changed, 3 insertions(+), 26 deletions(-) diff --git a/fs/udf/file.c b/fs/udf/file.c index 8a37cd593883..84e0b241940d 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -57,16 +57,6 @@ void udf_adinicb_readpage(struct page *page) kunmap_atomic(kaddr); } -const struct address_space_operations udf_adinicb_aops = { - .dirty_folio = block_dirty_folio, - .invalidate_folio = block_invalidate_folio, - .read_folio = udf_read_folio, - .writepages = udf_writepages, - .write_begin = udf_write_begin, - .write_end = udf_write_end, - .direct_IO = udf_direct_IO, -}; - static vm_fault_t udf_page_mkwrite(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 08788f4dab18..6d303f580232 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -364,8 +364,6 @@ int udf_expand_file_adinicb(struct inode *inode) iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT; else iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG; - /* from now on we have normal address_space methods */ - inode->i_data.a_ops = &udf_aops; set_page_dirty(page); unlock_page(page); up_write(&iinfo->i_data_sem); @@ -379,7 +377,6 @@ int udf_expand_file_adinicb(struct inode *inode) kunmap_atomic(kaddr); unlock_page(page); iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; - inode->i_data.a_ops = &udf_adinicb_aops; iinfo->i_lenAlloc = inode->i_size; up_write(&iinfo->i_data_sem); } @@ -1566,10 +1563,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode) case ICBTAG_FILE_TYPE_REGULAR: case ICBTAG_FILE_TYPE_UNDEF: case ICBTAG_FILE_TYPE_VAT20: - if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) - inode->i_data.a_ops = &udf_adinicb_aops; - else - inode->i_data.a_ops = &udf_aops; + inode->i_data.a_ops = &udf_aops; inode->i_op = &udf_file_inode_operations; inode->i_fop = &udf_file_operations; inode->i_mode |= S_IFREG; diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 1b0f4c600b63..c043584463d2 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -373,10 +373,7 @@ static int udf_create(struct user_namespace *mnt_userns, struct inode *dir, if (IS_ERR(inode)) return PTR_ERR(inode); - if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) - inode->i_data.a_ops = &udf_adinicb_aops; - else - inode->i_data.a_ops = &udf_aops; + inode->i_data.a_ops = &udf_aops; inode->i_op = &udf_file_inode_operations; inode->i_fop = &udf_file_operations; mark_inode_dirty(inode); @@ -392,10 +389,7 @@ static int udf_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, if (IS_ERR(inode)) return PTR_ERR(inode); - if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) - inode->i_data.a_ops = &udf_adinicb_aops; - else - inode->i_data.a_ops = &udf_aops; + inode->i_data.a_ops = &udf_aops; inode->i_op = &udf_file_inode_operations; inode->i_fop = &udf_file_operations; mark_inode_dirty(inode); diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index 304c2ec81589..d8c0de3b224e 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -80,7 +80,6 @@ extern const struct inode_operations udf_file_inode_operations; extern const struct file_operations udf_file_operations; extern const struct inode_operations udf_symlink_inode_operations; extern const struct address_space_operations udf_aops; -extern const struct address_space_operations udf_adinicb_aops; extern const struct address_space_operations udf_symlink_aops; struct udf_fileident_iter { From patchwork Wed Jan 25 09:41:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115353 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6658C27C76 for ; Wed, 25 Jan 2023 09:42:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235264AbjAYJmN (ORCPT ); Wed, 25 Jan 2023 04:42:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234640AbjAYJmE (ORCPT ); Wed, 25 Jan 2023 04:42:04 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C18F73D92E for ; Wed, 25 Jan 2023 01:42:02 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5C1641FD8D; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IvXHs7KC3XoYcieRWPWsX3JTLF6cKFBBMlbp8BGLHvw=; b=FbRu5Ubri2lpGIczpdxaKuIniPyxnTlc+/bY353WhKl9xoeCzA9hN2V8hf/C+Go5cfqVMl WRcux9Y6X9WZzM0+3/Qqsz+GI/XERWf3kP/UgABA3VSQICZJ2PFxQW7lYcqCTHqG5RUhtr obGh/7FjezVno9urTqyg9Fx40DfTsIU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IvXHs7KC3XoYcieRWPWsX3JTLF6cKFBBMlbp8BGLHvw=; b=CO27MhIh+nU1IhhYl9VE18TMwZzmiFIPl44p4871VKRbubWPKtyvccN/L+oVQtFMLhcZnc ahgupQNnYT0pU+CQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3BC6D13A06; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id v7mWDmn50GMoIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:01 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 673A5A06D4; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara , Christoph Hellwig Subject: [PATCH v2 08/12] udf: Mark aops implementation static Date: Wed, 25 Jan 2023 10:41:50 +0100 Message-Id: <20230125094159.10877-8-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3705; i=jack@suse.cz; h=from:subject; bh=KohlA3zDsUpsD8ncXHbnvUVHzj7Ra7hy/Db1qwCHeg0=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0PleGXh+EyMA738Koav7xfNO+Na2r1Gfngy+eE2w EwTYx7+JATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5XgAKCRCcnaoHP2RA2VQ4CA DKVDtjaN2RUdksGl3+rSycya/xkMt0NpIlP045KsdJ5l2tanQS0Z52mAbIvVRRJLe7tIYyjqpao1Gx dJSwwGW+cfiqTn8R7x8FM8s/DWixX4lBrEJdO7Bbuf2Q4yF28CpebFWwrpG1z4rsrFcThDDb/ZmUWq N42QyrP93qizHBH8yo3OH8Kkda4ZqU15gC/6dPcTzX3z4VdDwAliXNlaOKrMxVKADj2P91IU6LWDjC +XACcTbjLunvREmcYanQAaPsr+6QJaqDw3/Xd1CtARcWlbvHUjPHbaDbTIpAzfq7vPh8inIlWAjSvu bAKjFhdzUVHUFGmWjlL9dN2WU/MD6R X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Mark functions implementing aops static since they are not needed outside of inode.c anymore. Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/udf/inode.c | 19 ++++++++++--------- fs/udf/udfdecl.h | 9 --------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 6d303f580232..688ecf60edfa 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -204,7 +204,8 @@ static int udf_adinicb_writepage(struct page *page, return 0; } -int udf_writepages(struct address_space *mapping, struct writeback_control *wbc) +static int udf_writepages(struct address_space *mapping, + struct writeback_control *wbc) { struct inode *inode = mapping->host; struct udf_inode_info *iinfo = UDF_I(inode); @@ -214,7 +215,7 @@ int udf_writepages(struct address_space *mapping, struct writeback_control *wbc) return write_cache_pages(mapping, wbc, udf_adinicb_writepage, NULL); } -int udf_read_folio(struct file *file, struct folio *folio) +static int udf_read_folio(struct file *file, struct folio *folio) { struct udf_inode_info *iinfo = UDF_I(file_inode(file)); @@ -231,9 +232,9 @@ static void udf_readahead(struct readahead_control *rac) mpage_readahead(rac, udf_get_block); } -int udf_write_begin(struct file *file, struct address_space *mapping, - loff_t pos, unsigned len, - struct page **pagep, void **fsdata) +static int udf_write_begin(struct file *file, struct address_space *mapping, + loff_t pos, unsigned len, + struct page **pagep, void **fsdata) { struct udf_inode_info *iinfo = UDF_I(file_inode(file)); struct page *page; @@ -257,9 +258,9 @@ int udf_write_begin(struct file *file, struct address_space *mapping, return 0; } -int udf_write_end(struct file *file, struct address_space *mapping, - loff_t pos, unsigned len, unsigned copied, - struct page *page, void *fsdata) +static int udf_write_end(struct file *file, struct address_space *mapping, + loff_t pos, unsigned len, unsigned copied, + struct page *page, void *fsdata) { struct inode *inode = file_inode(file); loff_t last_pos; @@ -277,7 +278,7 @@ int udf_write_end(struct file *file, struct address_space *mapping, return copied; } -ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter) +static ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter) { struct file *file = iocb->ki_filp; struct address_space *mapping = file->f_mapping; diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index d8c0de3b224e..337daf97d5b4 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -158,15 +158,6 @@ extern struct buffer_head *udf_bread(struct inode *inode, udf_pblk_t block, extern int udf_setsize(struct inode *, loff_t); extern void udf_evict_inode(struct inode *); extern int udf_write_inode(struct inode *, struct writeback_control *wbc); -int udf_read_folio(struct file *file, struct folio *folio); -int udf_writepages(struct address_space *mapping, struct writeback_control *wbc); -int udf_write_begin(struct file *file, struct address_space *mapping, - loff_t pos, unsigned len, - struct page **pagep, void **fsdata); -int udf_write_end(struct file *file, struct address_space *mapping, - loff_t pos, unsigned len, unsigned copied, - struct page *page, void *fsdata); -ssize_t udf_direct_IO(struct kiocb *iocb, struct iov_iter *iter); extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *, struct kernel_lb_addr *, uint32_t *, sector_t *); int udf_get_block(struct inode *, sector_t, struct buffer_head *, int); From patchwork Wed Jan 25 09:41:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115358 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B0A2C54EED for ; Wed, 25 Jan 2023 09:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234783AbjAYJmS (ORCPT ); Wed, 25 Jan 2023 04:42:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235130AbjAYJmF (ORCPT ); Wed, 25 Jan 2023 04:42:05 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29FC6869F for ; Wed, 25 Jan 2023 01:42:04 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6633621C87; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PLOgGtlxgWk8Df8C9rOhCqDe5ikolSIjDExntNB6zB8=; b=mk4gbM8nZdoOY4AT69M+/5ltfjTeTBEQkQpgQtQGFNhrrO0bLhVFKesEfP83tve1ajpXiI H+U8RpKXjES0mPc6PrRYORcxD1Zhn99solQcMQtQiBp8q0ac/0ffWRB/5NSmdaI3rYYl1D Q2ZMTt5H07Omhpgy0M/2ptOdH7gWcOI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PLOgGtlxgWk8Df8C9rOhCqDe5ikolSIjDExntNB6zB8=; b=K+KcV0VZEA9xexbuFEsUCHN1WC7F5c/s4n67EPyP2qqYrwq6QopRzi/PMaUAv+XsqcBeAT oDxgDxO/ozQtvCAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4D8B913A08; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id dhPqEmn50GMsIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:01 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 6DBA1A06D5; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara , Christoph Hellwig Subject: [PATCH v2 09/12] udf: Move udf_adinicb_readpage() to inode.c Date: Wed, 25 Jan 2023 10:41:51 +0100 Message-Id: <20230125094159.10877-9-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2662; i=jack@suse.cz; h=from:subject; bh=E063OJasYfEby9ECqJUZOB5MJLzFH2niRlYkJ3uG2ys=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0Pleg8XHnjrtvW4K8igHaDKjDlQwiLKC5O4+O8lp Obe+UjuJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5XgAKCRCcnaoHP2RA2SFZCA CxrZNmCapBoPT7zZe+02zzObJp/HRoV0im46eKHwXzcM+cp8a2VMCj6bf6AmFLFVVTw7d0O/QjKVzH 53QzHaOWX0DVgRAS0f6FbjFoeTYYDkcuOLemdJGwW/XZAcwQr5jYnLGknYk8Tl0nLB4LretfwnATNL HcckyoNgZ5tBFL7Tx5+3rQekpxb0g5K9LiyAKQh1J8v/mlszwGUUcSGEy/TVL1UggX/LO855AYHHh9 IwHZUmgwybchMNjpspt54uRwbf5hvSeL1J8wq4OKzG9fEQkrcBwHOXwCrD4IVA+WWN0bYabkMhVmbE PPkzd3CTEphYo0DhqjmXeXJ6y/zwmc X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org udf_adinicb_readpage() is only called from aops functions, move it to the same file as its callers and also drop the stale comment - invalidate_lock is protecting us against races with truncate. Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/udf/file.c | 19 ------------------- fs/udf/inode.c | 15 +++++++++++++++ fs/udf/udfdecl.h | 1 - 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/fs/udf/file.c b/fs/udf/file.c index 84e0b241940d..26592577b7da 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -38,25 +38,6 @@ #include "udf_i.h" #include "udf_sb.h" -void udf_adinicb_readpage(struct page *page) -{ - struct inode *inode = page->mapping->host; - char *kaddr; - struct udf_inode_info *iinfo = UDF_I(inode); - loff_t isize = i_size_read(inode); - - /* - * We have to be careful here as truncate can change i_size under us. - * So just sample it once and use the same value everywhere. - */ - kaddr = kmap_atomic(page); - memcpy(kaddr, iinfo->i_data + iinfo->i_lenEAttr, isize); - memset(kaddr + isize, 0, PAGE_SIZE - isize); - flush_dcache_page(page); - SetPageUptodate(page); - kunmap_atomic(kaddr); -} - static vm_fault_t udf_page_mkwrite(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 688ecf60edfa..dc59b119d9ac 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -215,6 +215,21 @@ static int udf_writepages(struct address_space *mapping, return write_cache_pages(mapping, wbc, udf_adinicb_writepage, NULL); } +static void udf_adinicb_readpage(struct page *page) +{ + struct inode *inode = page->mapping->host; + char *kaddr; + struct udf_inode_info *iinfo = UDF_I(inode); + loff_t isize = i_size_read(inode); + + kaddr = kmap_atomic(page); + memcpy(kaddr, iinfo->i_data + iinfo->i_lenEAttr, isize); + memset(kaddr + isize, 0, PAGE_SIZE - isize); + flush_dcache_page(page); + SetPageUptodate(page); + kunmap_atomic(kaddr); +} + static int udf_read_folio(struct file *file, struct folio *folio) { struct udf_inode_info *iinfo = UDF_I(file_inode(file)); diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index 337daf97d5b4..88692512a466 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -137,7 +137,6 @@ static inline unsigned int udf_dir_entry_len(struct fileIdentDesc *cfi) /* file.c */ extern long udf_ioctl(struct file *, unsigned int, unsigned long); -void udf_adinicb_readpage(struct page *page); /* inode.c */ extern struct inode *__udf_iget(struct super_block *, struct kernel_lb_addr *, From patchwork Wed Jan 25 09:41:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115356 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A723BC54E94 for ; Wed, 25 Jan 2023 09:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235302AbjAYJmR (ORCPT ); Wed, 25 Jan 2023 04:42:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235008AbjAYJmE (ORCPT ); Wed, 25 Jan 2023 04:42:04 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2FED2716 for ; Wed, 25 Jan 2023 01:42:03 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5BDF921C86; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ntIqIWP+u7LqYWu9VpJ1s00Imo/AG1DtfaRXmHaXZz4=; b=LabvqNLeuYFvY37m5rl2zhrkTDHa0cPn0pikJevYt+Sh4zrxNgDP0e9RR49GfF0FUiAiCL Gv3EihgJ52YAEJU+WRY0Qv2d0apnWjhY2DvM2KDcYRwlSz7V9hJY7IOma4P2fZ4dDhFf0n t+r/fTt+lk23livRSrTAkbRNPg/sRaY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ntIqIWP+u7LqYWu9VpJ1s00Imo/AG1DtfaRXmHaXZz4=; b=H59AhP3dUp/I1ffiXrFH/nexErXUW+B1J3JhX4QZ2MQNcOnbvZlCk5gxGaJDGcaPwgV5f3 nfKC1BZL2ePmLsAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3BC1D1358F; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0/6TDmn50GMqIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:01 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 734E2A06D7; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara , Christoph Hellwig Subject: [PATCH v2 10/12] udf: Switch udf_adinicb_readpage() to kmap_local_page() Date: Wed, 25 Jan 2023 10:41:52 +0100 Message-Id: <20230125094159.10877-10-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=910; i=jack@suse.cz; h=from:subject; bh=HY/6cWAzv/GdBpBJvLctrA1mkb/5yrEe4/zrDB/jyRE=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0Plf9uOOJ5oY2zfwiZlrHfOeQeyClOD19y7BcLV3 p3GLqGOJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5XwAKCRCcnaoHP2RA2eRlB/ 9KnY+WDrnOryrvViOFRoNdauhxKXuBOf17xYegRZt4UnzK04HSL/N/IXas+ejADIR5fMC5NcOss02S e/FWhH8q/hKcnUIM8gSLs2Pvz2r2XkA+Zm+bRut3sEsFlxAfiV9nUN/yzAtFEp6qqqW/kK+gb7GUT0 aYTlp8TDw3nvxP6tWAl8N+y/LGSDNggAPxrLewOmuigFOmeJE4+5kSp24wSIBAvkS2xyEYQVsT/Qd/ tqjvyI9GdH2PiQu+rafvtGzMtB8XGr48xbRCw5af7rQ3zY/xOa6bJOE1zmSh+Nuk/FZVuQWtKcrfU5 uyTZbT5MkY8FOSWYa46jBhfG2uWEye X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Instead of using kmap_atomic() use kmap_local_page() in udf_adinicb_readpage(). Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/udf/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index dc59b119d9ac..7e3aca596bcf 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -222,12 +222,12 @@ static void udf_adinicb_readpage(struct page *page) struct udf_inode_info *iinfo = UDF_I(inode); loff_t isize = i_size_read(inode); - kaddr = kmap_atomic(page); + kaddr = kmap_local_page(page); memcpy(kaddr, iinfo->i_data + iinfo->i_lenEAttr, isize); memset(kaddr + isize, 0, PAGE_SIZE - isize); flush_dcache_page(page); SetPageUptodate(page); - kunmap_atomic(kaddr); + kunmap_local(kaddr); } static int udf_read_folio(struct file *file, struct folio *folio) From patchwork Wed Jan 25 09:41:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115354 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8A24C54EED for ; Wed, 25 Jan 2023 09:42:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235285AbjAYJmO (ORCPT ); Wed, 25 Jan 2023 04:42:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235066AbjAYJmE (ORCPT ); Wed, 25 Jan 2023 04:42:04 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D19433EC46 for ; Wed, 25 Jan 2023 01:42:02 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 705B81FEDA; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yqD9uKDnI3HPWvas6RtM9zNOgMIU0VQV5ATdQusFkWI=; b=1O9y8xOHNS6hvR6DKaOh/3qJahXJNZF8ndtjDMGkfgD3XuK3+hbNLWnxiULYEse00+Cl3x IF0pYli0PYOxifpOcgdgjySw4ExrP4l/dw0WCqPOXS2/s403hoQ11t6RXg2DA9k9KCF9ro NQVkEdMnIwHDoN+M24bKPQ/j2O9jhjA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yqD9uKDnI3HPWvas6RtM9zNOgMIU0VQV5ATdQusFkWI=; b=p6SO1a/jnjghWvNWEJgDhj8L88/7s481Hd80tKNslX+Rv2mf/VbwMbCCCx8SLRJ4B2TK0e AHH1OPN94NQfgsAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5AEAC13A0F; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IR4rFmn50GMxIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:01 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 782C0A06D8; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara Subject: [PATCH v2 11/12] udf: Convert udf_adinicb_writepage() to memcpy_to_page() Date: Wed, 25 Jan 2023 10:41:53 +0100 Message-Id: <20230125094159.10877-11-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1001; i=jack@suse.cz; h=from:subject; bh=dhFeQH5IiopDQxnKUKJGGcbwk9AWq9rK5bsPaj/RUos=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0PlgMQ7Wy6ITz+YbzVzICd0WNE8+cUmgLHB48E/N R3c8SdWJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5YAAKCRCcnaoHP2RA2WqGB/ 9j5XinJ2NN4JJYGmsniVbnkci/wNgc7809A4TrTdmtNRv+22JusundJiLyWaIDVKUEL3mzkDjjQl0k 3Ew4BhdtLNB1t8m4GdHfkp9jWGHZu54ox3iITkw8qLePQ+JoeGCcUiOphZW8h9fXwF0tTkz7JPeNez woIkHUZiHlJCeU3juJBp11NrLYKhMFjkiOnstZ5h/nKmeC0BbX5fthyvO0v/PKN1ijDITyOTHraQRf SJgOjZr5qye+ltMSIBpujmAEmvSzgVTAjwiq96oOyvVjEWZsihbFbGSqi67a2/ll8yjBDFrkiU71Q+ 7Mi8LGjlTgyCLJd1y/qNH5DeB+XUtj X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Instead of mapping the page manually with kmap() atomic, use helper memcpy_to_page(). Also delete the pointless SetPageUptodate() call. Signed-off-by: Jan Kara --- fs/udf/inode.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 7e3aca596bcf..66e491626d74 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -189,16 +189,11 @@ static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc, void *data) { struct inode *inode = page->mapping->host; - char *kaddr; struct udf_inode_info *iinfo = UDF_I(inode); BUG_ON(!PageLocked(page)); - - kaddr = kmap_atomic(page); - memcpy(iinfo->i_data + iinfo->i_lenEAttr, kaddr, i_size_read(inode)); - SetPageUptodate(page); - kunmap_atomic(kaddr); - unlock_page(page); + memcpy_to_page(page, 0, iinfo->i_data + iinfo->i_lenEAttr, + i_size_read(inode)); mark_inode_dirty(inode); return 0; From patchwork Wed Jan 25 09:41:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13115355 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17761C27C76 for ; Wed, 25 Jan 2023 09:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235286AbjAYJmP (ORCPT ); Wed, 25 Jan 2023 04:42:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235071AbjAYJmE (ORCPT ); Wed, 25 Jan 2023 04:42:04 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3DBC3EC48 for ; Wed, 25 Jan 2023 01:42:02 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 739771FED6; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eXDtyCUNu5VoYwlS7xsHDzk4XKyktknG43RJia0BStM=; b=rNPWudjkbfa4dXeGjnfeQdxVYpUN+yk1O1BSzkSgjUJQs8r/+wXQVIv177xZEidY58ct2K 4esPnoPm/VyXX0TaPAJbjAPfJQmXm0plkK2SHG1aAsqgH5Zok3FInennzNxke5C/+3x/5q RGK81F0WQrWs8tG4MNA18eeL5zyBuu4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674639721; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eXDtyCUNu5VoYwlS7xsHDzk4XKyktknG43RJia0BStM=; b=lKj9yxk5hmtm5x82CrAQNsCptMpPE3KgbLTl+wqaptfbwPpVJexxbv9ZhXF3c62Lmh45h2 IUWiAi5lX8l50fDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 57C7513A0A; Wed, 25 Jan 2023 09:42:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hwUOFWn50GMwIgAAMHmgww (envelope-from ); Wed, 25 Jan 2023 09:42:01 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 7E0CFA06E1; Wed, 25 Jan 2023 10:41:59 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , Jan Kara Subject: [PATCH v2 12/12] udf: Convert udf_expand_file_adinicb() to avoid kmap_atomic() Date: Wed, 25 Jan 2023 10:41:54 +0100 Message-Id: <20230125094159.10877-12-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125093914.24627-1-jack@suse.cz> References: <20230125093914.24627-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1833; i=jack@suse.cz; h=from:subject; bh=rA0hx6VLz0r/esxyZcHhWvmu94EpK1SGsJn5IxzPb/M=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj0PlhLYB2c3wQGjoioYt03PmJOrLrEaahb5zMLcZ5 /Q65GvKJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY9D5YQAKCRCcnaoHP2RA2VENCA CgsWjjHye7W2BwSqoPHtPH32I87/reHlv3GY0QD2SGwPuUR9kqK/nd/ipTbhT+0xUD4/s594gVtmkn TxLygKozp/56DL8mMFNFRB0xTqJldbHu4h354KNjOmMpM15KWhCAXdZYjWfLR3a4qyh1/dlO5oxONt KX/xJyuTNqdjeaH3QMz6cnPwo2lEFmgqF+xLW4YCGdUbH1Mitl6dujlNjUqa/kz3JmlVQj8XBajFVc wfHQv7xnV8GYGjJVew15SRyTwNYlo4ssPEPdco5lGVwrCrEWh0V3NFKq3lUAyJgnkwGR+a1lMFmwer Qx6EMFgf1xios9g/FYyGDbDKuvX1wP X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Remove the last two remaining kmap_atomic() uses in UDF in udf_expand_file_adinicb(). The first use can be actually conveniently replaced with udf_adinicb_readpage(), the second with memcpy_to_page(). Signed-off-by: Jan Kara --- fs/udf/inode.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 66e491626d74..0ef2f8e5d301 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -335,7 +335,6 @@ const struct address_space_operations udf_aops = { int udf_expand_file_adinicb(struct inode *inode) { struct page *page; - char *kaddr; struct udf_inode_info *iinfo = UDF_I(inode); int err; @@ -357,16 +356,8 @@ int udf_expand_file_adinicb(struct inode *inode) if (!page) return -ENOMEM; - if (!PageUptodate(page)) { - kaddr = kmap_atomic(page); - memset(kaddr + iinfo->i_lenAlloc, 0x00, - PAGE_SIZE - iinfo->i_lenAlloc); - memcpy(kaddr, iinfo->i_data + iinfo->i_lenEAttr, - iinfo->i_lenAlloc); - flush_dcache_page(page); - SetPageUptodate(page); - kunmap_atomic(kaddr); - } + if (!PageUptodate(page)) + udf_adinicb_readpage(page); down_write(&iinfo->i_data_sem); memset(iinfo->i_data + iinfo->i_lenEAttr, 0x00, iinfo->i_lenAlloc); @@ -383,9 +374,8 @@ int udf_expand_file_adinicb(struct inode *inode) /* Restore everything back so that we don't lose data... */ lock_page(page); down_write(&iinfo->i_data_sem); - kaddr = kmap_atomic(page); - memcpy(iinfo->i_data + iinfo->i_lenEAttr, kaddr, inode->i_size); - kunmap_atomic(kaddr); + memcpy_to_page(page, 0, iinfo->i_data + iinfo->i_lenEAttr, + inode->i_size); unlock_page(page); iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; iinfo->i_lenAlloc = inode->i_size;