Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1814066rbb; Tue, 27 Feb 2024 01:51:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOa1K5gvcSjSBc/1yPhxJo7VtCZ2bdbsLdoxXlCUcWrR2mXyWTW9PFp/Oftdyc64AQOzMUpLmwFVeNUZ2VnheRR9rNwyx2YTutdtoX2Q== X-Google-Smtp-Source: AGHT+IFo481sb+4Ia9ZaGqDK+2IsU8GjIh1abxsLNqB7CMzKu/b5UEgEfeGWi2RwGFc0kQE6cJh0 X-Received: by 2002:a05:622a:1a05:b0:42e:1f4a:72ac with SMTP id f5-20020a05622a1a0500b0042e1f4a72acmr9735569qtb.56.1709027467637; Tue, 27 Feb 2024 01:51:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709027467; cv=pass; d=google.com; s=arc-20160816; b=FxugSqajGXdOA5A0jDMO7Vk0s/ShAqviroO4tDB+hbHZttsZXiSETBbQpz+0nPITG/ 2eS+Ui1kfRY7sI0V5rgknqLtrdwy1t972fTjANlLZKLOM1d8h6eJkex7vvxHA/N2vRUP EOzisRLsnjQfnRsCTRnZJgZSVR+9l7rHjWuCS9wpxO/JyJ8k+0KmqldQVaXMtNqguOx6 X5PGHTabHsL+9jhGGHlvaXK4405CbFAwFvWIfUxOPwbEsZOoqQaoFb3KUG5Axx2UDvkH pJ7rbpSAYoxXE8Ff6HvLSS2vj1wy64hgkPNHPZrzjRYkeIFf3H012zF9M922E7QQoDAi rTBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=50P6BtmSu6TZY3fumWs04okJUU6PUrVTmELjj8/MjQM=; fh=EvLWc2r8Rx1LBrXB2M+bGi8FX8z9/YzSTJ47CJeltA0=; b=XO1PYaRKvBzBKVS14/EGyWATM7fEcBuIZs9IHQvsSd+t8oWG29B8SVTLilioky034C joqxAqNbDQixS8iqF7JdmbiZReiiC5do61Bwts0MywDKJvMj0hxj+OGBG7ZLVKFcSyc9 clsVS7P4wmqthw1TBfZrSb73p/isT4/XTbk5Bx/xJL2VvqjUt8vFtri6T0/+Tis4cyd3 m1pTtRBOJRX3WAFiD+WlWilYRqVvBGKF391s6ZgD0/tFYROrFYK7FVe+c6iMp6NMRVBB 2PJ4OGIgSNJxfVZ2crFOEy6WFl/blnHJsnMKK0u/3tJwFR/tmLy0qBUOOtAUPec0rGTR P+tQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=GMTPJcrf; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-82966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82966-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v21-20020ac87495000000b0042e76fe2083si6261212qtq.86.2024.02.27.01.51.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 01:51:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=GMTPJcrf; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-82966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82966-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CD51F1C2269A for ; Tue, 27 Feb 2024 09:33:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 474D31369B5; Tue, 27 Feb 2024 09:33:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b="GMTPJcrf" Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45A291369A4; Tue, 27 Feb 2024 09:33:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709026411; cv=none; b=pcrgCPezf3N72MM+txGNLL83F/7rp023GMuo7b+uJzGXvbKpD0/V7RrwgYKN3L1W2OcxE3sfKBwOElKfKZPSkIwT0zpto9AAHC9dW7fiKJjvnOI1BoY+yZ76ZJylz8ISksKB3r9sILZbYRG1iXe6Ed6bH0d61jEmRR9tAc7vF70= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709026411; c=relaxed/simple; bh=ihSb31MveA511qLCYqgRAbr0VwITsxdL+t6Pn6z4hzI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Oag7/HPqWDCCPT9X9XjGfmTe4lFScqsvg1/RYGnuvav0skgRFPMaypq5EI/XtXZpYPxbk00+5p83DYltmtkXqvl5+baGzynrmdmmDcQ9x/wE4oAAZ0JwoRJOlySGZ5cHFTWBh/AqrP4QwjivoMdJzvnY2mU1mLAjLRVion0hw28= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pankajraghav.com; spf=pass smtp.mailfrom=pankajraghav.com; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b=GMTPJcrf; arc=none smtp.client-ip=80.241.56.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pankajraghav.com Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4TkXNP5Jv6z9smD; Tue, 27 Feb 2024 10:33:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1709026405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=50P6BtmSu6TZY3fumWs04okJUU6PUrVTmELjj8/MjQM=; b=GMTPJcrfqTMcvvlrwwI/f3bHzERGH6KsPCu9OUPYazsskmeLvpmeO2lKMnMCcfDSSOAL/R dvmZqZmKX3dpt0/QjiDz34yjHWSWM4GA9r3AYl9RpAD3SGErX8Nxkx2bkbWZTV5mIHcmE8 5gXSdvlqZLUCp3JKTKITpHBav6Ci6w6NNuL96JeCu8vQUDzSLs0RN533WXRkPxFnEZFlBr 6spw7PuDKhZl5kqWFsLeXR4kLcSs98VHR4rxMlaeTg/OpZvqxllaR/OfDKv5fiD59OKo60 a6E2UIlHVi6c4Wy5PW8/I/+BcTT4z41Myx2eckvXAhAtwQeMCWJk3mF0tQzk0w== Date: Tue, 27 Feb 2024 10:33:21 +0100 From: "Pankaj Raghav (Samsung)" To: Matthew Wilcox Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org, mcgrof@kernel.org, ziy@nvidia.com, hare@suse.de, djwong@kernel.org, gost.dev@samsung.com, linux-mm@kvack.org, Pankaj Raghav Subject: Re: [PATCH 10/13] iomap: fix iomap_dio_zero() for fs bs > system page size Message-ID: <3pqmgrlewo6ctcwakdvbvjqixac5en6irlipe5aiz6vkylfyni@2luhrs36ke5r> References: <20240226094936.2677493-1-kernel@pankajraghav.com> <20240226094936.2677493-11-kernel@pankajraghav.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: > I thought we were going to use the huge_zero_page for this? Yes. We discussed that huge_zero_page might fail, so we concluded that we needed an api that can return arbitrary folio order that will not fail: ``` your point about it possibly failing is correct. so i think we need an api which definitely returns a folio, but it might be of arbitrary order. ``` I couldn't come up with implementing your latter suggestion, so I informed darrick that let's use this patch for now, and add the arbitrary folio order with zero as a later enhancement. If we want to use mm_huge_zero_page, then this should work: diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 04f6c5548136..b6a3f52f48da 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -237,10 +237,17 @@ static void iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, { struct inode *inode = file_inode(dio->iocb->ki_filp); struct page *page = ZERO_PAGE(0); + struct folio *folio = NULL; struct bio *bio; WARN_ON_ONCE(len > (BIO_MAX_VECS * PAGE_SIZE)); + if (len > PAGE_SIZE) { + page = mm_get_huge_zero_page(current->mm); + if (!page) + page = ZERO_PAGE(0); + } + bio = iomap_dio_alloc_bio(iter, dio, BIO_MAX_VECS, REQ_OP_WRITE | REQ_SYNC | REQ_IDLE); fscrypt_set_bio_crypt_ctx(bio, inode, pos >> inode->i_blkbits, @@ -249,13 +256,15 @@ static void iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, bio->bi_iter.bi_sector = iomap_sector(&iter->iomap, pos); bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; + folio = page_folio(page); while (len) { - unsigned int io_len = min_t(unsigned int, len, PAGE_SIZE); + size_t size = min(len, folio_size(folio)); - __bio_add_page(bio, page, io_len, 0); - len -= io_len; + bio_add_folio_nofail(bio, folio, size, 0); + len -= size; } + iomap_dio_submit_bio(iter, dio, bio, pos); } Let me know if we should go for this or let's keep the original patch and add a ZERO_FOLIO_ORDER API that will not fail and use it as a later enhancement.