Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5219961pxv; Tue, 20 Jul 2021 23:36:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/1ea6Z8B7242XWrivDtWxFa2TERukOcgpjcI/iCawjoHi8KRpd2e4Q0OU9/XtWiLo/fnN X-Received: by 2002:a92:d5cf:: with SMTP id d15mr23029506ilq.194.1626849379988; Tue, 20 Jul 2021 23:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626849379; cv=none; d=google.com; s=arc-20160816; b=tZWJPUYDb8ENWWlvRULQpeT3SIb7Ld9S0Dd8uJk9hNwbdqpvIdvlzPrYR0dTRpNc1u CkQMBcofTXI5hG+hvZlOt7ejztKOcVFIvLRmKdsEvNGpxTqr3F0AAyxA0i1ApyvYZwpy 5ImOLqGVDNPfvvr290newgNR4TbkhC1m+3f4aCkUkOjUgqN7EJyQKErbhY4qcJNu3odV 1ULW+bqjIRi7/6OUmcaUv3lMA7wgBxP54N9isoidBQ6VHfhC1GJr5fRlR6kOX5juZqfM +uOiTns2a30rfnbpHf0TGAL9T7bK9Si6q1kx60u2h8vDBt68DN8K5nKJLHt4Kl+7RHbK tuvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vgZ3yjomTzlMCFEBY2QOLzdcWRgyC4eVhW9WC+FWjOI=; b=rL/KWnx79TQAKNToIMKjOeU4abeCaSAB7+KtAGHzlkgASDUi+KC7pONzcF6/B2NY2R 97Y2p2OdD41dRABvNtXliJaH2tlR5fYm48Fom5iaOC+y+WL70D5mzD80IhHCQ3p+Kr+7 e6fgUSMBjX8odCtQNXyDPsTedZlum7/euDqtaO/avHkKardT1LX2CyARI2WnRfE+meT/ nTs5CEZwIx5HlgqgnvyeHY8pC2P6IavpV8cZpXa7irG3x2goPorecnbLftevlYQEbWRX xxmNnw2y7YbVQ6HQan6DeBC2xHo+MZbnS/EqZIvbX+47oMn0O9N7QIY6wZ8BBxoH3oV8 0zjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tQ8qIzLK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o7si14054899jao.123.2021.07.20.23.36.08; Tue, 20 Jul 2021 23:36:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tQ8qIzLK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233917AbhGUFyq (ORCPT + 99 others); Wed, 21 Jul 2021 01:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234063AbhGUFyW (ORCPT ); Wed, 21 Jul 2021 01:54:22 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9826CC0613DD; Tue, 20 Jul 2021 23:33:44 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id u14so1647673ljh.0; Tue, 20 Jul 2021 23:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vgZ3yjomTzlMCFEBY2QOLzdcWRgyC4eVhW9WC+FWjOI=; b=tQ8qIzLK6bqfVALG6GEQIfaZ1m2r/Tt4OX9AAorqyfmfoAwESt4rRHHYH0nAgWXreX E2KEoOx7x+Rhh2FpIqFlWiShWxY4PF6BxxXHhR9FWt5NADi5LtM0j7RSYef6HUAWrQ0A yAUdS0e4zRfrVDi97stCd4s35iRLaQriRr4i6hBE3DRw0TTgVFYLqnitHUsAIgjpJo6d aYobLw59ffWcESJoaSaBgyc7RfHLWj11PRqyhEXU/trsyv9lY2wSEzmPraBWS65tsnAR V9L+Ayhxlw/BOSY1QCg5YVU4EQKvYx8vtXYW0PiySFH21XLCgRlI/6hDVYtOS1uB8NyO KktA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vgZ3yjomTzlMCFEBY2QOLzdcWRgyC4eVhW9WC+FWjOI=; b=jKVc7tHngy9DBb9sS6qgspAMuv3uZPZvR4NxtBO2SOBcn29ubRBXwlToxK47KcBpYs KziNZq2xymjZlszcl70AlgMZv0Q+jyiOvpzmwGnpSQ0F6+qNekmUEc+XYCwLi5xA+3bP nChF4dnADXbkG1xwlk+aORUv0zQIwVxAMz6w9J8P0+SGK2D++RBDoH+2unMGPVrNlFLl LqI0fx0qoQvp3OnXiHHuPpcdyPaQ1fOhKqEBAufG1cJesuragI5lOQg6MD+R3Z7kwyRx /EhVcRAm5FpKO3AbYiQnxAgS95p1COKiKoF5HUC9g9Fzxct2PggtuElFNECpXlJLKnFd Ee/A== X-Gm-Message-State: AOAM533tHVddIycFDvFizFe+RwrRagjJL6944RcPCm5m4x9Axu5MJZrT ehu8LNLNqdK5DuZPrLf5bIEod0ISGR6hjczH0BY= X-Received: by 2002:a2e:a5c6:: with SMTP id n6mr29681111ljp.204.1626849222792; Tue, 20 Jul 2021 23:33:42 -0700 (PDT) MIME-Version: 1.0 References: <20210720133554.44058-1-hsiangkao@linux.alibaba.com> <20210720204224.GK23236@magnolia> In-Reply-To: From: =?UTF-8?Q?Andreas_Gr=C3=BCnbacher?= Date: Wed, 21 Jul 2021 08:33:30 +0200 Message-ID: Subject: Re: [PATCH v4] iomap: support tail packing inline read To: Matthew Wilcox Cc: "Darrick J. Wong" , Gao Xiang , linux-erofs@lists.ozlabs.org, Linux FS-devel Mailing List , LKML , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Di., 20. Juli 2021 um 23:19 Uhr schrieb Matthew Wilcox : > On Tue, Jul 20, 2021 at 01:42:24PM -0700, Darrick J. Wong wrote: > > > - BUG_ON(page_has_private(page)); > > > - BUG_ON(page->index); > > > - BUG_ON(size > PAGE_SIZE - offset_in_page(iomap->inline_data)); > > > + /* inline source data must be inside a single page */ > > > + BUG_ON(iomap->length > PAGE_SIZE - offset_in_page(iomap->inline_data)); > > > > Can we reduce the strength of these checks to a warning and an -EIO > > return? Yes, we could do that. > I'm not entirely sure that we need this check, tbh. I wanted to make sure the memcpy / memset won't corrupt random kernel memory when the filesystem gets the iomap_begin wrong. > > > + /* handle tail-packing blocks cross the current page into the next */ > > > + size = min_t(unsigned int, iomap->length + pos - iomap->offset, > > > + PAGE_SIZE - poff); > > > > > > addr = kmap_atomic(page); > > > - memcpy(addr, iomap->inline_data, size); > > > - memset(addr + size, 0, PAGE_SIZE - size); > > > + memcpy(addr + poff, iomap->inline_data - iomap->offset + pos, size); > > > + memset(addr + poff + size, 0, PAGE_SIZE - poff - size); > > > > Hmm, so I guess the point of this is to support reading data from a > > tail-packing block, where each file gets some arbitrary byte range > > within the tp-block, and the range isn't aligned to an fs block? Hence > > you have to use the inline data code to read the relevant bytes and copy > > them into the pagecache? > > I think there are two distinct cases for IOMAP_INLINE. One is > where the tail of the file is literally embedded into the inode. > Like ext4 fast symbolic links. Taking the ext4 i_blocks layout > as an example, you could have a 4kB block stored in i_block[0] > and then store bytes 4096-4151 in i_block[1-14] (although reading > https://www.kernel.org/doc/html/latest/filesystems/ext4/dynamic.html > makes me think that ext4 only supports storing 0-59 in the i_blocks; > it doesn't support 0-4095 in i_block[0] and then 4096-4151 in i_blocks) > > The other is what I think erofs is doing where, for example, you'd > specify in i_block[1] the block which contains the tail and then in > i_block[2] what offset of the block the tail starts at. Andreas