From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2FA96FBF for ; Mon, 1 Jul 2024 02:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719801436; cv=none; b=r34/zPxXMJjEf+lJRlihkeURrv85axr5ayRIhLZeBkqEdQv/iqWVtnN/9kPiDeZCHpWYnkeOomjHg1rtjfHfXPfFivG9unUOGl/986OKZgTFMPzu8G+d85hM/A8R12qSo6LcbXNBNvtlSjtYY6e6Je8exNxnLlDTv4IY+0nKLaU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719801436; c=relaxed/simple; bh=lqwELc+8R6n7oIAYBPBASK/w4I25XITcOSCEwq6tAxw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MLUFpv6z1H8O06d8v02LLKkxRj0lzsvT1ls0btnWXJw8ihWnuxQz0Y40IKawP+fPO11F53enxifu5r0AsHuCe6GZxzOe/YqZPGJHmp48w5dKVp5gKeQ99af9i1EWPipvc8jTD9kn0KdF4IPSGRF/kPFZ2dEGoOP0ftKvHz2+NMo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com; spf=pass smtp.mailfrom=fromorbit.com; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b=NrV5CDNg; arc=none smtp.client-ip=209.85.161.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fromorbit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b="NrV5CDNg" Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-5c427f3695cso1231785eaf.3 for ; Sun, 30 Jun 2024 19:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1719801434; x=1720406234; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=m0rcRCi2FGvgQgr9Zpkb36TAwmq6Gr7fbHDsnURXNUg=; b=NrV5CDNgIRrGPzcNNOjfnQ/zuIwjUg9MzCf8pvoPTUMDsp46T4C5UmZgSoqCwY6Jky qcKzIGy9GohMuMkwp/8leAYEGBDDRzSekcEXYK2+aco3iGs3QkUJc4AVZTFDpK9gLREx etFTC47NGkOr3rj8sHbMbB5b2H75gN3eiJqnDUxQcU2alRcRvHqZXIF2jJhxJ0eapaMm eCrlJo46a/7Mcspx0wneCyA7jFTZ27W1iYI8EeakGzYIxlCTDaYWOKeQE2jTkZKoAjgw O9i4WY6d1p0xBom9g9Wd+SIg8RCsPwsmAJJWFE+FqmL1WCEszljK5sPvXx285sEz5yEc 3XYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719801434; x=1720406234; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=m0rcRCi2FGvgQgr9Zpkb36TAwmq6Gr7fbHDsnURXNUg=; b=BqhshQjzl6Z3dChS+gQ0FzBgKt6lE2HYaeI/h5n+gErWQWSV+wUKWKof61ABo8YXD5 Zs0Q6In9s2h67kDxpSSYiy/JHHdDqv6Q1bB6AqK52zwqQOZ3sYCogOQpV446j4xoT8gA 9ttcq0NfiA6cF9MinJaIfBDZ7pAJNxlAs/lBniWPqaAof12NLakW9lGAVIz0hE0tcjWe kmb4U6PZjn2yQojeTNPN9+eQccm9kW0omRSjydvCHDXF1YFlxNdvydeTjsHYEBGSIfeZ ER9R6p6lWXmFpC+SnUixKAf6Ib3LtiSNdVsx+Nap8X0rsOUG0qQ994JlR2AgUfkVOcJV GkEA== X-Forwarded-Encrypted: i=1; AJvYcCW2V49m33XCzeA8543+Vya/ew5J2R7W4bO2l/fhJSjOEq9RyuS6nDfPulxdny+oDhPSeBllcH0TCShyUJCO5iRvova5FxK7gxRw/8FP X-Gm-Message-State: AOJu0YwiAZ1Q5IZDoU6VOHfTPZQ7ThFKsEJasBeT8OWXl5cbQ0zQhFNZ vK+hnIxezxZhIDPOqsFivE9tiYF/PJR8jJEs4RjNRquX3L6t1OZu7pLngh7a8DQ= X-Google-Smtp-Source: AGHT+IEKU7/ErAzsurHPsktSpR5wwiSvxcXhKtFFLIUsLHdEdFgaLynxClPU/fi5/wA2tx9Ll0sAmg== X-Received: by 2002:a05:6358:9201:b0:1a4:b69d:a197 with SMTP id e5c5f4694b2df-1a6acef5ae5mr474319155d.29.1719801434005; Sun, 30 Jun 2024 19:37:14 -0700 (PDT) Received: from dread.disaster.area (pa49-179-32-121.pa.nsw.optusnet.com.au. [49.179.32.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91ce17a77sm5548654a91.6.2024.06.30.19.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 19:37:13 -0700 (PDT) Received: from dave by dread.disaster.area with local (Exim 4.96) (envelope-from ) id 1sO6uk-00HR7V-2U; Mon, 01 Jul 2024 12:37:10 +1000 Date: Mon, 1 Jul 2024 12:37:10 +1000 From: Dave Chinner To: "Pankaj Raghav (Samsung)" Cc: willy@infradead.org, chandan.babu@oracle.com, djwong@kernel.org, brauner@kernel.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, yang@os.amperecomputing.com, linux-mm@kvack.org, john.g.garry@oracle.com, linux-fsdevel@vger.kernel.org, hare@suse.de, p.raghav@samsung.com, mcgrof@kernel.org, gost.dev@samsung.com, cl@os.amperecomputing.com, linux-xfs@vger.kernel.org, hch@lst.de, Zi Yan Subject: Re: [PATCH v8 06/10] iomap: fix iomap_dio_zero() for fs bs > system page size Message-ID: References: <20240625114420.719014-1-kernel@pankajraghav.com> <20240625114420.719014-7-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: <20240625114420.719014-7-kernel@pankajraghav.com> On Tue, Jun 25, 2024 at 11:44:16AM +0000, Pankaj Raghav (Samsung) wrote: > From: Pankaj Raghav > > iomap_dio_zero() will pad a fs block with zeroes if the direct IO size > < fs block size. iomap_dio_zero() has an implicit assumption that fs block > size < page_size. This is true for most filesystems at the moment. > > If the block size > page size, this will send the contents of the page > next to zero page(as len > PAGE_SIZE) to the underlying block device, > causing FS corruption. > > iomap is a generic infrastructure and it should not make any assumptions > about the fs block size and the page size of the system. > > Signed-off-by: Pankaj Raghav > Reviewed-by: Hannes Reinecke Looks fine, so: Reviewed-by: Dave Chinner but.... > +/* > + * Used for sub block zeroing in iomap_dio_zero() > + */ > +#define ZERO_PAGE_64K_SIZE (65536) > +#define ZERO_PAGE_64K_ORDER (get_order(ZERO_PAGE_64K_SIZE)) > +static struct page *zero_page_64k; ..... > @@ -753,3 +765,17 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, > return iomap_dio_complete(dio); > } > EXPORT_SYMBOL_GPL(iomap_dio_rw); > + > +static int __init iomap_dio_init(void) > +{ > + zero_page_64k = alloc_pages(GFP_KERNEL | __GFP_ZERO, > + ZERO_PAGE_64K_ORDER); > + > + if (!zero_page_64k) > + return -ENOMEM; > + > + set_memory_ro((unsigned long)page_address(zero_page_64k), > + 1U << ZERO_PAGE_64K_ORDER); ^^^^^^^^^^^^^^^^^^^^^^^^^ isn't that just ZERO_PAGE_64K_SIZE? -Dave. -- Dave Chinner david@fromorbit.com