From patchwork Thu Feb 9 12:31:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13134478 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 73A27C636D3 for ; Thu, 9 Feb 2023 12:32:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 743906B0071; Thu, 9 Feb 2023 07:32:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A3CD6B007D; Thu, 9 Feb 2023 07:32:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 408066B0071; Thu, 9 Feb 2023 07:32:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1422B6B0071 for ; Thu, 9 Feb 2023 07:32:13 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BF3C3C0E0B for ; Thu, 9 Feb 2023 12:32:12 +0000 (UTC) X-FDA: 80447690904.26.0A66272 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf02.hostedemail.com (Postfix) with ESMTP id 7285580015 for ; Thu, 9 Feb 2023 12:32:10 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=CqmvW0jJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tq6vAYDB; spf=pass (imf02.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675945930; 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=qvuorklveraurLcK6QZ4mrS02HsJE4d+WeMXOh2Sd9M=; b=hwC4xFlAZ5gzhXc3v5BPjwlCy44PPM1QOWQnj2EdyORJPeZTy/L4zQjAkQgtwm41ZZJI4/ QVIiU8lj+SY0SBvMFr+T0ZEajZ2Fo02n3dW3sRYZ1u+cVC/Sfg9NkiDEZ3+UJwP0+RZuQ9 ++745CXojAa4uOsAlUGi/FoDlgMyhaA= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=CqmvW0jJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tq6vAYDB; spf=pass (imf02.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675945930; a=rsa-sha256; cv=none; b=Py921W8ktfxVjOb7M4uFz1vRo08iK4vn90Ocy9D+JK7Ok5pE0rV0gABl69m8uEQGQEDQ9r 6GaeK7/Ycsa39SWhisPoAp3258b0JLBns5TMp+0rGlVhmbxu6d2I/AkXSBDap10Y9MJU6Q 7xotGZCl7oBUG0yYXw3RcIhdKUknr1E= 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 1DB3937478; Thu, 9 Feb 2023 12:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1675945929; 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=qvuorklveraurLcK6QZ4mrS02HsJE4d+WeMXOh2Sd9M=; b=CqmvW0jJ3DIGd+grXAIql03BHQqGkK991C6Wi/E2LQDYyC81PqbbRNsLN58sTPW/f9eeNR 46Q2L1SdgD4NsmyatNgmANAy47H6LO4bS097sh7idyKKRF8Fxtd0K+pcd9/acCE2hE5R1h JueXPVPxo906sx84zxJWyIaa/eQRZ0E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1675945929; 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=qvuorklveraurLcK6QZ4mrS02HsJE4d+WeMXOh2Sd9M=; b=tq6vAYDBQAPD+mTUztBhpxRGG5W7kgIlBecfOjKwc5V3IHSaF7kmh4eqHKEyrF+eRPINmE 5ib8Hi0bQ3OvJgAQ== 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 11748138E4; Thu, 9 Feb 2023 12:32:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 7Jg8BMnn5GPGWQAAMHmgww (envelope-from ); Thu, 09 Feb 2023 12:32:09 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 982C7A06F2; Thu, 9 Feb 2023 13:32:06 +0100 (CET) From: Jan Kara To: Cc: , , John Hubbard , David Howells , David Hildenbrand , Jan Kara Subject: [PATCH 5/5] iomap: Bounce pinned pages during writeback Date: Thu, 9 Feb 2023 13:31:57 +0100 Message-Id: <20230209123206.3548-5-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230209121046.25360-1-jack@suse.cz> References: <20230209121046.25360-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1103; i=jack@suse.cz; h=from:subject; bh=jvs7yXeGV+Ti+9CbBYnSlNBqaLxxaizxHND1BJeW90M=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBj5Oe8w55rhlFdINcQXnpIh1RKW3XbWlfIU3Y2TDA8 67+oTNmJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY+TnvAAKCRCcnaoHP2RA2fhCB/ 4/2JpDK+0V232sGOIsqPKWw7XV7L4ti40Cg3tBEmAVQxehU+I8NK4CzzdA8EZTSvTLVZqxg5+/M6s3 bmQbCDaG0JJs98lmbFy1SWxxvOXgww4EXeQpC6BQVC6JuPMfUp8ZF5WKOy6NLsB07ZacUYwIXp3+iH vAYxabUp7I4r/qYnPszdwAwfSxdRNLzAMYlIdHglipFfjmmyjszncki6Qtux7gBGcygYWRXcHByucy 7NvP6kGl4qovVvUreW7xU027/wR8JU4aOpC5Eg+x3McBfThsCPvBFXez0gjVOSfunRnsQ9YoCL3hPj Ucbv/ceayUl3fYswgCPMwHjX26Fu+/ X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Stat-Signature: hackaue6s7d1q8pjzn9aauigprwz56xr X-Rspam-User: X-Rspamd-Queue-Id: 7285580015 X-Rspamd-Server: rspam06 X-HE-Tag: 1675945930-585501 X-HE-Meta: U2FsdGVkX19u/K91yBcV52yAkCkLtA7AuzloxEQlc8ij7Se9bhq0G4suTVDQMAF7g3wGaCufngtkam+fCVhRPfzysHvwQPPlsLFA3QCkFtOrQfX4lyW+nVOvF+61en/gn3VBbfWKrLm4HOjg2cbEF2KG8iWI7v/MKFtxUlu/G1nk9CNQv1lJGtAvqUoLtPvFaxPxZllK3hiAW+b5zoV3mMR4kt0+8yGXqWtkIcgue8aRVgbzQfTEI7O8SR0AAHdaXrVtMXmhkUfyQGIROx+0Lc92lrZtUXXgBYi3oVPa+giztCofo6AI91VrAGwTRyTDM9tTXXvzu/BtDm0YsdrW8RciehGsE7xaT68X3lKKZl9N/YCte4fVurEGhjNJLRXMiAcEb7UgjRaoy2VXOi4FTVJLU5FFK2VBTj1dT7ANYHNz8S6+dY121eZd52h/EhewF/XuygJFZhOsIRV29E5H4pBDvZZ+3sejI4wxe/YvwIqHARju9Box87w5FTOrZOX3Ahu4N0X+aRevjyvNl/Q0maNKpGHKqaGhjqcORdlu21MrH4SC7+fF0mF4O54IuJ89xKrdvAzeVJuu8UObneXqeKdLmekoiPKlGA27b7x6qco6zRXKKgVsqYX9t/DgsBoGwfKFKcteYQ/CJAre3NKxqJJeA/t5gg2/rS2Mn3Z7c8blkLMe6L2pV2z3COlCrC67Itz5Gui7YyCDXx3UtcJyiv/NwwSvi1251z76dAKaLIJOgsNc0A9n18MjXeOO+Kmo6q9PR7bcweL/lgFdPpDKSHPZh52LyA3Lb5v+7GmR5+eOc66Pf17w9sKUrF3d6VgNQT9KuUEaCioAQu1rCEkloCDCow3LuBvfhrstxC2NC+F0xgoiJcoF9TI8xbyRRXw2vkVa848rPg4hqBCE16n2QnxJ/fct5TeE+8m3PH3nB/TidlqeauxMD2RcTjyvwt8NV01mtTXgIdKYuoDlH/0 VKV774vg A7anSZY5Ke01Qab+z0cu8V58Vg6miDM7qTEoDmYtoks3lrT7lxAiTGQzSd7xKeuyVK189mnXycJ6O5wXqXW2cmvDElfZ62UQ8MZhiH9QJ+SzFzm0VSxwr9LUCDP0tRWikHE7QfisQat3PwHoLCh9VsprCKLrpYNizU3jvn8K9K//YIcwmi0eCXVqAy9Vv5VSJheKUpjC1Eep9ypU= 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: When there is direct IO (or other DMA write) running into a page, it is not generally safe to submit this page for writeback because this can cause DIF/DIX failures or similar issues. Ask block layer to bounce the page in this case. Signed-off-by: Jan Kara --- fs/iomap/buffered-io.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 356193e44cf0..e6469e7715cc 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1563,6 +1563,14 @@ iomap_add_to_ioend(struct inode *inode, loff_t pos, struct folio *folio, bio_add_folio(wpc->ioend->io_bio, folio, len, poff); } + /* + * Folio may be modified by the owner of the pin and we require stable + * page contents during writeback? Ask block layer to bounce the bio. + */ + if (inode->i_sb->s_iflags & SB_I_STABLE_WRITES && + folio_maybe_dma_pinned(folio)) + wpc->ioend->io_bio->bi_flags |= 1 << BIO_NEED_PIN_BOUNCE; + if (iop) atomic_add(len, &iop->write_bytes_pending); wpc->ioend->io_size += len;