From patchwork Sun Dec 29 13:38:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922681 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 C5F361531C8 for ; Sun, 29 Dec 2024 13:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479536; cv=none; b=nAndZkrzcL84FGzKIgqUOGLD7cgRTtThfZSHQWCi3pa+8MLwOH0EohYqz6HoRWi8FavXyvSUCIE7jNxYfEl3JxZLmynTa9v1kTHws0a7oUJy7orO4FL3jSG4UHm9UCavDIm1oHBcqrMdDw7jnRVb0mg7+1yAQjLG9oRg2I1xlAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479536; c=relaxed/simple; bh=kxPe4iVy8cfXDJreWP8Pt1QLN8EVveJqg39cW/XQiHs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ge3qcu+OpDRI3iZfAsqXrK19g9ks9qA8VV5BM9DtdswmJdK4bZtdWUnBbcjV2y7UMf2sWaw2Ks5DBlYt7MyIXKg0G9+1kWgTxgbQOdTFhAkTNDlnRvuURz+ZN+QZJpB9tmuyXdFcC4LzTbU/Y2lvncpKC2Msh9kcNpi2NLl8b0A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WI8YwiMU; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WI8YwiMU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479533; h=from:from:reply-to:subject:subject: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=/zZXrzyOsl6xfQYeEnalw30bjT7COLAi5eAiBDs0mSE=; b=WI8YwiMUYBo1JWvf9UKDGcwbmTLanTvpmOEXdQNoBtBuxZ89Z5G4gHtwx9R9d5NPQGjGH4 uBfHB54YQl28o1OG2a2RR8SPuoyErSW1fTOFChec4CfoaoNBGnnJfXAgbceEhwzbVB7ScG n4rywXooUzd1OQPLwl3yiA8BhfQP+vA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558--ekqFzJLPxmm-F3RpL8C5A-1; Sun, 29 Dec 2024 08:38:52 -0500 X-MC-Unique: -ekqFzJLPxmm-F3RpL8C5A-1 X-Mimecast-MFC-AGG-ID: -ekqFzJLPxmm-F3RpL8C5A Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4359206e1e4so67762635e9.2 for ; Sun, 29 Dec 2024 05:38:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479530; x=1736084330; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/zZXrzyOsl6xfQYeEnalw30bjT7COLAi5eAiBDs0mSE=; b=hxCPvzqpxy0TddJ1SUuZTKaX3fUQJE/K02sa0lEmp9lR2GTnYBwUXlRLO17qkILaGc Ap3j1AC6gWKLe5rHugVgeYYK2Im9Rka2kTaVFH51qMPpaF4riH+7W3G37C1iP/euzeGp HfVF5DNMOBcg03xbcbQeUYiZn38oyND7QshR0UcePN6ol9Bq5jGvJZr9bx+7MgWl3bJ4 rTt5gE21FaBDmc20hR46NsNFnFPbU+pdhYXgZXY2ekJPtTZKAS+qvd2jCXmHlUvYNKot Hd8kpwPltxLEe0H+vO2s3vyHGycuXtD47COS3YjJmqtY2tNh+j8h9wJ/ghfegV5cJt9o LSmg== X-Gm-Message-State: AOJu0YwgvDHeyjf4+VpbS7xdGwO+PuXrLXPIkXpH38OSn+1VAzl0LoEr 1K6aaDS6ZPaL2SWstLpbG9oOT/2ZQvdvI91epokVA96RYJqdrga/tHEut7FHnb+SEVK+0ihCy6Q dvxNIWprk8tw8VE97jqZU/jdPk6nBP6eAqbOt3qNNrljckQn1h2FrpeDLQGB5Rzf8c2eIs6qVW4 ExLtCjFwhSf4Pb6UM4JlVR+IlWV8/CZWyiKSSstP4B X-Gm-Gg: ASbGncuzHULHfLlwMwfO1RABI96ipIEbQmMs8p/g1ytf6wB3o4tPDV9hnoCr/VBgAEZ 8lrN8MXu229OCVizHjhkkgivcDZgx8j0u5h3akEOcdMFJioBFx0qRkt/QC7OI/QqSrNg0NZNbnR 7WYFFeL89Ysw/7M/zvJ85DaVjPAymDnrsONFjdP4J4hTIgBiJoHhdbxK1ZVHJIsWBONZBz4wYUt LA+d36w9MRx/FRB8eb/6TuVVoiCHakAgZEHvKb1hUl17fvS5yaDi5xNFhtu672dwCiKtdHvlFdd aGqPw4KRras9xFw= X-Received: by 2002:a05:600c:4709:b0:436:1ac2:1acf with SMTP id 5b1f17b1804b1-43668a3a35dmr247083475e9.20.1735479530551; Sun, 29 Dec 2024 05:38:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHtf7A57Lm/8C8shYrRZeaxy4+osMFkjjSCIKKSDFZ2bFlMclRie5Wi2KENF6Snjko31IZKw== X-Received: by 2002:a05:600c:4709:b0:436:1ac2:1acf with SMTP id 5b1f17b1804b1-43668a3a35dmr247083285e9.20.1735479530160; Sun, 29 Dec 2024 05:38:50 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:38:49 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 01/14] iomap: add wrapper to pass readpage_ctx to read path Date: Sun, 29 Dec 2024 14:38:23 +0100 Message-ID: <20241229133836.1194272-2-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make filesystems able to create readpage context, similar as iomap_writepage_ctx in write path. This will allow filesystem to pass _ops to iomap for ioend configuration (->prepare_ioend) which in turn can be used to set BIO end callout (bio->bi_end_io). Signed-off-by: Andrey Albershteyn --- fs/iomap/buffered-io.c | 76 ++++++++++++++++++++++++------------------ include/linux/iomap.h | 12 +++++++ 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 0f33ac975209..0d9291719d75 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -320,14 +320,6 @@ static void iomap_read_end_io(struct bio *bio) bio_put(bio); } -struct iomap_readpage_ctx { - struct folio *cur_folio; - bool cur_folio_in_bio; - struct bio *bio; - struct readahead_control *rac; - int flags; -}; - /** * iomap_read_inline_data - copy inline data into the page cache * @iter: iteration structure @@ -461,28 +453,27 @@ static loff_t iomap_read_folio_iter(const struct iomap_iter *iter, return done; } -int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops) +int iomap_read_folio_ctx(struct iomap_readpage_ctx *ctx, + const struct iomap_ops *ops) { + struct folio *folio = ctx->cur_folio; struct iomap_iter iter = { .inode = folio->mapping->host, .pos = folio_pos(folio), .len = folio_size(folio), }; - struct iomap_readpage_ctx ctx = { - .cur_folio = folio, - }; int ret; trace_iomap_readpage(iter.inode, 1); while ((ret = iomap_iter(&iter, ops)) > 0) - iter.processed = iomap_read_folio_iter(&iter, &ctx); + iter.processed = iomap_read_folio_iter(&iter, ctx); - if (ctx.bio) { - submit_bio(ctx.bio); - WARN_ON_ONCE(!ctx.cur_folio_in_bio); + if (ctx->bio) { + submit_bio(ctx->bio); + WARN_ON_ONCE(!ctx->cur_folio_in_bio); } else { - WARN_ON_ONCE(ctx.cur_folio_in_bio); + WARN_ON_ONCE(ctx->cur_folio_in_bio); folio_unlock(folio); } @@ -493,6 +484,16 @@ int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops) */ return 0; } +EXPORT_SYMBOL_GPL(iomap_read_folio_ctx); + +int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops) +{ + struct iomap_readpage_ctx ctx = { + .cur_folio = folio, + }; + + return iomap_read_folio_ctx(&ctx, ops); +} EXPORT_SYMBOL_GPL(iomap_read_folio); static loff_t iomap_readahead_iter(const struct iomap_iter *iter, @@ -520,6 +521,30 @@ static loff_t iomap_readahead_iter(const struct iomap_iter *iter, return done; } +void iomap_readahead_ctx(struct iomap_readpage_ctx *ctx, + const struct iomap_ops *ops) +{ + struct readahead_control *rac = ctx->rac; + struct iomap_iter iter = { + .inode = rac->mapping->host, + .pos = readahead_pos(rac), + .len = readahead_length(rac), + }; + + trace_iomap_readahead(rac->mapping->host, readahead_count(rac)); + + while (iomap_iter(&iter, ops) > 0) + iter.processed = iomap_readahead_iter(&iter, ctx); + + if (ctx->bio) + submit_bio(ctx->bio); + if (ctx->cur_folio) { + if (!ctx->cur_folio_in_bio) + folio_unlock(ctx->cur_folio); + } +} +EXPORT_SYMBOL_GPL(iomap_readahead_ctx); + /** * iomap_readahead - Attempt to read pages from a file. * @rac: Describes the pages to be read. @@ -537,26 +562,11 @@ static loff_t iomap_readahead_iter(const struct iomap_iter *iter, */ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops) { - struct iomap_iter iter = { - .inode = rac->mapping->host, - .pos = readahead_pos(rac), - .len = readahead_length(rac), - }; struct iomap_readpage_ctx ctx = { .rac = rac, }; - trace_iomap_readahead(rac->mapping->host, readahead_count(rac)); - - while (iomap_iter(&iter, ops) > 0) - iter.processed = iomap_readahead_iter(&iter, &ctx); - - if (ctx.bio) - submit_bio(ctx.bio); - if (ctx.cur_folio) { - if (!ctx.cur_folio_in_bio) - folio_unlock(ctx.cur_folio); - } + iomap_readahead_ctx(&ctx, ops); } EXPORT_SYMBOL_GPL(iomap_readahead); diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 3297ed36c26b..b5ae08955c87 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -296,9 +296,21 @@ static inline bool iomap_want_unshare_iter(const struct iomap_iter *iter) iter->srcmap.type == IOMAP_MAPPED; } +struct iomap_readpage_ctx { + struct folio *cur_folio; + bool cur_folio_in_bio; + struct bio *bio; + struct readahead_control *rac; + int flags; +}; + ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from, const struct iomap_ops *ops, void *private); +int iomap_read_folio_ctx(struct iomap_readpage_ctx *ctx, + const struct iomap_ops *ops); int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops); +void iomap_readahead_ctx(struct iomap_readpage_ctx *ctx, + const struct iomap_ops *ops); void iomap_readahead(struct readahead_control *, const struct iomap_ops *ops); bool iomap_is_partially_uptodate(struct folio *, size_t from, size_t count); struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos, size_t len); From patchwork Sun Dec 29 13:38:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922682 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 1130B15820C for ; Sun, 29 Dec 2024 13:38:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479537; cv=none; b=NPFPykSR5R1lzk9LfXXVmE3hx6o8XjFz6Jevseq+3oV70RCsNKuvVoGmJR5uzK3Ln+wRDevqEggnG466dLYPXUydaUxVTJKBouxYLCoc+QlDoUUxfNQ5N+vHwtO5AaXKLWLTXJvcF/UJfNynoDn3SxdJPYXDm3n/k/bzMoPOrvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479537; c=relaxed/simple; bh=tgU6IAOsE2grady0FRgR/Vk19r/ZJ9XttjxbfOcwPv0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lT7wxjGDs+LqgAVSWu/7lNFvaW/uAG7zcOY95hHshxSiokUD4DDeOfKeG1tcOSvJu85ecsvjfvaozaiRcF+mI9zO4BNPSjmxF2mmXrNLC70wuzaF6+YNhgEVxizyLDdSN7FiSE5o/woFGhK4HYuPlIrW669btVbEIvTeCj8qCZ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Vd9DsEvQ; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Vd9DsEvQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479535; h=from:from:reply-to:subject:subject: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=9tm77WUuBRFcTEQqs42woSPBEv4TWV3Fg/m6UO05FCU=; b=Vd9DsEvQgutGQteDNSnju3SN4H7vqBV3t5KAzB+F2fbBVUuG1ZVLVxjgTrvfQnmtEebDaz bmQjSkq6CkS//17ooYlL1NkNDSk1hac/qpm6Q0YDCbQwYyX8FrwB7P/qN5qfxdpACYSHXc pkZeukkx77LIou7RLDhR04ckycDPFKo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-bGYN72OqMyS0qJtolC-muw-1; Sun, 29 Dec 2024 08:38:53 -0500 X-MC-Unique: bGYN72OqMyS0qJtolC-muw-1 X-Mimecast-MFC-AGG-ID: bGYN72OqMyS0qJtolC-muw Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43628594d34so10048035e9.2 for ; Sun, 29 Dec 2024 05:38:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479532; x=1736084332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9tm77WUuBRFcTEQqs42woSPBEv4TWV3Fg/m6UO05FCU=; b=aqEfMY+R82RP4dLvC2UyXMJMMHH4RS/S8e1oK7wHw8CtRKIsKHM1l/pw3U1+1OGTSO 7B4k4sGaekxuk632zO4JTDR3+vE8s3eZMr2AerjlI8wJjy/yw1lkaIy4ZhcqgmI2zJYb hilUzgZ0BU8tgHsU9mxTuiKl+IGpYw8h6uQBnDGWkrPSHNQdDlpfkbGVOZGdLwCz0B5G q8KQCKD5njLDlE60AuMi3xUGzgDita848S+8aggQOihJ9nVOc2cVbrn4NEAQ3F4vivTd R1CUSFcpXmwU0TRj0fUJ6Dlb8yzkrVj2uWzoYC4h+UHAcTVEpc6wx61x6KuHoFmiy9dP oByQ== X-Gm-Message-State: AOJu0YxIOdpl6Cl8Q9Dyk5JC+vpxSA3KgLzcawNCFqFpmtc9MH8TIs+9 N7XVACYkNf9zzci5UyHZysd393Y3Tk5iPNtNnhiaEWKvQdKQDrXZdOjCfWoguc2qiWOkum1zZpR G5eE+sUY1CzVJSwwgaksGHHTwyVT0mVQf4M3E3R3PKcOX2fu81NJY5IGjMUZ7UYkiZgeISXxmk0 E5u37/KMCy9qiJvm1fxiKgjz3Xtt1z1YhMQW1GO194 X-Gm-Gg: ASbGncteRWQ8iArRy2yIScCL4W0/zynmpTQ3eDnnQXJPmJUVrJMXdaShxRl1abDSsTy +2rKpEAlRWr5E2KfDAwxflEVhc9be9K1GgJjPB/wTiXHA4FnNDc8/kiRPTZPJqN/64DqCfwfnYw xwIASGG/Y3PRMgAqIEezcy3cVLbwAS1Uy7HYeNAZAZfhNmxuINu4j+2VXPRO/LycNipQY1MPWLz nObwx1diFKM+3UNrcaoarb6WdbBYXhVCKR3a5Q9dElyZSIMpv15fKmqyGS+8JT09ndxJXziArph FGM8GinBuCv6pQo= X-Received: by 2002:a05:600c:350c:b0:434:fdaf:af2d with SMTP id 5b1f17b1804b1-43668b7850emr285632275e9.30.1735479531839; Sun, 29 Dec 2024 05:38:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGqpDcZjNVnlNEs9PXqbwn99rIC/70CE8FQwCSVGMYtS+kEK0U9GbyExlQDK/vP6Zm4GVD3A== X-Received: by 2002:a05:600c:350c:b0:434:fdaf:af2d with SMTP id 5b1f17b1804b1-43668b7850emr285632105e9.30.1735479531435; Sun, 29 Dec 2024 05:38:51 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:38:50 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 02/14] iomap: add read path ioends for filesystem read verification Date: Sun, 29 Dec 2024 14:38:24 +0100 Message-ID: <20241229133836.1194272-3-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andrey Albershteyn Add iomap_readpage_ops with only optional ->prepare_ioend() to allow filesystem to add callout used for configuring read path ioend. Mainly for setting ->bi_end_io() callout. Make iomap_read_end_io() exportable, so, it can be called back from filesystem callout after verification is done. The read path ioend are stored side by side with BIOs allocated from iomap_read_ioend_bioset. Signed-off-by: Andrey Albershteyn --- fs/iomap/buffered-io.c | 31 ++++++++++++++++++++++++++----- include/linux/iomap.h | 20 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 0d9291719d75..93da48ec5801 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -41,6 +41,7 @@ struct iomap_folio_state { }; static struct bio_set iomap_ioend_bioset; +static struct bio_set iomap_read_ioend_bioset; static inline bool ifs_is_fully_uptodate(struct folio *folio, struct iomap_folio_state *ifs) @@ -310,7 +311,7 @@ static void iomap_finish_folio_read(struct folio *folio, size_t off, folio_end_read(folio, uptodate); } -static void iomap_read_end_io(struct bio *bio) +void iomap_read_end_io(struct bio *bio) { int error = blk_status_to_errno(bio->bi_status); struct folio_iter fi; @@ -319,6 +320,7 @@ static void iomap_read_end_io(struct bio *bio) iomap_finish_folio_read(fi.folio, fi.offset, fi.length, error); bio_put(bio); } +EXPORT_SYMBOL_GPL(iomap_read_end_io); /** * iomap_read_inline_data - copy inline data into the page cache @@ -371,6 +373,8 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter, loff_t orig_pos = pos; size_t poff, plen; sector_t sector; + struct iomap_read_ioend *ioend; + const struct iomap *srcmap = iomap_iter_srcmap(iter); if (iomap->type == IOMAP_INLINE) return iomap_read_inline_data(iter, folio); @@ -407,21 +411,29 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter, if (ctx->rac) /* same as readahead_gfp_mask */ gfp |= __GFP_NORETRY | __GFP_NOWARN; - ctx->bio = bio_alloc(iomap->bdev, bio_max_segs(nr_vecs), - REQ_OP_READ, gfp); + ctx->bio = bio_alloc_bioset(iomap->bdev, bio_max_segs(nr_vecs), + REQ_OP_READ, gfp, &iomap_read_ioend_bioset); /* * If the bio_alloc fails, try it again for a single page to * avoid having to deal with partial page reads. This emulates * what do_mpage_read_folio does. */ if (!ctx->bio) { - ctx->bio = bio_alloc(iomap->bdev, 1, REQ_OP_READ, - orig_gfp); + ctx->bio = bio_alloc_bioset(iomap->bdev, 1, + REQ_OP_READ, orig_gfp, &iomap_read_ioend_bioset); } if (ctx->rac) ctx->bio->bi_opf |= REQ_RAHEAD; ctx->bio->bi_iter.bi_sector = sector; ctx->bio->bi_end_io = iomap_read_end_io; + ioend = container_of(ctx->bio, struct iomap_read_ioend, + io_bio); + ioend->io_inode = iter->inode; + ioend->io_flags = srcmap->flags; + ioend->io_offset = poff; + ioend->io_size = plen; + if (ctx->ops && ctx->ops->prepare_ioend) + ctx->ops->prepare_ioend(ioend); bio_add_folio_nofail(ctx->bio, folio, plen, poff); } @@ -2157,6 +2169,15 @@ EXPORT_SYMBOL_GPL(iomap_write_region); static int __init iomap_buffered_init(void) { + int error = 0; + + error = bioset_init(&iomap_read_ioend_bioset, + 4 * (PAGE_SIZE / SECTOR_SIZE), + offsetof(struct iomap_read_ioend, io_bio), + BIOSET_NEED_BVECS); + if (error) + return error; + return bioset_init(&iomap_ioend_bioset, 4 * (PAGE_SIZE / SECTOR_SIZE), offsetof(struct iomap_ioend, io_bio), BIOSET_NEED_BVECS); diff --git a/include/linux/iomap.h b/include/linux/iomap.h index b5ae08955c87..f089969e4716 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -296,14 +296,34 @@ static inline bool iomap_want_unshare_iter(const struct iomap_iter *iter) iter->srcmap.type == IOMAP_MAPPED; } +struct iomap_read_ioend { + struct inode *io_inode; /* file being read from */ + u16 io_flags; /* IOMAP_F_* */ + size_t io_size; /* size of the extent */ + loff_t io_offset; /* offset in the file */ + struct work_struct io_work; /* post read work (e.g. fs-verity) */ + struct bio io_bio; /* MUST BE LAST! */ +}; + +struct iomap_readpage_ops { + /* + * Optional, allows the file systems to perform actions just before + * submitting the bio and/or override the bio bi_end_io handler for + * additional verification after bio is processed + */ + void (*prepare_ioend)(struct iomap_read_ioend *ioend); +}; + struct iomap_readpage_ctx { struct folio *cur_folio; bool cur_folio_in_bio; struct bio *bio; struct readahead_control *rac; int flags; + const struct iomap_readpage_ops *ops; }; +void iomap_read_end_io(struct bio *bio); ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from, const struct iomap_ops *ops, void *private); int iomap_read_folio_ctx(struct iomap_readpage_ctx *ctx, From patchwork Sun Dec 29 13:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922683 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 656171531C8 for ; Sun, 29 Dec 2024 13:38:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479538; cv=none; b=olfq0j13YzrhkeBzCkEW88Nsvwf7dNRrvzzznsfayBkzgP/F6i4LHV6ZMSpkHIGUZawOdQsyN+xQhrgsFC/X8nlUlN5KoPjp3NRITSYz+SdBU/zZZ4CTiikqcSdpH4Rxztai7117oWSBJBzFo/jBK4QTjPhhQvnnw4yPemTJE0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479538; c=relaxed/simple; bh=xmZB17e1ctO0w+tRaqjoeTT4ax83k4gqfbI9W8TxpVo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a15NFjlJVwid1KP7B5dyib4/rPU4CtKGpSjy/ZyEiw2j/bgOu/UUi40cnAtd7o7ra4vwi3JYKf/dBh0zQ9GVa2p9NV930epTURxN+lVv6l6Cs5FLSJ3Xx9FZL/Y3Q5XVCx1H3XtXd/qN4HC3s6155GP7MmNea9hJaag0YQTVF8s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XiWNXYgK; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XiWNXYgK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479536; h=from:from:reply-to:subject:subject: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=mlJE1BaTlse1OjGFNGszEZ9VdHnyKCI1Rx3qmWfoCOw=; b=XiWNXYgKXl/evGbQEObDJWFw0E3fngPMJSBvbGsBFBxNkHBYqQAbWRB0rQbY8SDN0PQssI qiTF2Z+YBRL+Sv7mbiNqldVxEYxmkp3OnSbbMKdxUYmx2q9c0UOs2Rfs3zWi1zFNSC9Jd/ UX5CRBk4yUpqAcOvqzhfO6H1caFw1Mk= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-303-WxqeeEhINsapv1Curuofuw-1; Sun, 29 Dec 2024 08:38:55 -0500 X-MC-Unique: WxqeeEhINsapv1Curuofuw-1 X-Mimecast-MFC-AGG-ID: WxqeeEhINsapv1Curuofuw Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-436723bf7ffso49567035e9.3 for ; Sun, 29 Dec 2024 05:38:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479533; x=1736084333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mlJE1BaTlse1OjGFNGszEZ9VdHnyKCI1Rx3qmWfoCOw=; b=Mpwao9ah7gjT6pRHXjAYGnXEj5mXX6SiSOuNjY1HeRafTYHDPfubabwgLOaL5NjVO2 z6KnYe0rTexg6Oe4mTNV/aJiAXc3KD1ycqSmLAK8CEl6/8UjEgVWR0I0MhPFJtbmmLeZ WaPLzQqbBRbyAE7lpAXGBHAUWcfGx8uGouf7axqxje/BsIMGwBZU9bTvA24+Ji3ZYmY6 VBh3xV9zJggdAYdvERdXByTOixPVr3f0S4HZir5DvXNXYBdcjXAYqY0P9aumWG6HmIgG F7ZSJ5H6eyrwd+ukBscIOyP20RiWSDjKWrPU6qln0g7CFH4sfszoz6Phmm5HE2l8Gkga W0UQ== X-Gm-Message-State: AOJu0YyzhQLYcgS/3hQviiMbJx4O8DnqKFEcuYGtCaZ1iRQgctaSA9LX /d7jFlVkw4wA5mAsvPcmW5LK9sIohBBhAjY7xnubL7QXamD3kFPaYjgxEkC1k6GaRhmNBbXN2RK h46DcYV9mJBgQ4N8iig8fvCvcKP5yg6X7D4qNr+PVrN/j5yhK3ZgQOJZgAX8up/5owEoGEt+dEd 1mUmDF7I7ekP8BdcfsHY8RGKs2eTTLekN9/HyBxYs8 X-Gm-Gg: ASbGnctbic3mWsELXGV7afsqhwZZlYoP3292K1Lan2i5x1SxgAmEGAMP1WCSMxvr+uC 8tnXkaduDG2EInAjqqc1sOCCqUC8akpkZ2Z0XG7jhfN7eESehmJ4oDE8KgBlZGPC1/9DR6lFTzl cEMsRn1iBzvPPFmJmkrgRegiUwmUEBnoi+lCLmCEMVrlgUy3kDDnkc5r1NIQCWBf/zNe+03H0jz I7+Ge/3hzPqgiznAKqTS/sZKY2DVCEm6yaU0Lfpp5ttfk4Lhgl2hZ7i3B5YZXBCjxocG5PTmDES +aTUeDqkzPWvA98= X-Received: by 2002:a05:600c:35cb:b0:436:1baa:de1c with SMTP id 5b1f17b1804b1-4366854c186mr272513235e9.13.1735479532675; Sun, 29 Dec 2024 05:38:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUXtCUFh8mSdGkZTOFcwXIdyMvofdws43jDP24o1Ht2UgYjrfXs+LljdB7IHFY1WRQHRQ6aQ== X-Received: by 2002:a05:600c:35cb:b0:436:1baa:de1c with SMTP id 5b1f17b1804b1-4366854c186mr272513085e9.13.1735479532258; Sun, 29 Dec 2024 05:38:52 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:38:51 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 03/14] iomap: introduce IOMAP_F_NO_MERGE for non-mergable ioends Date: Sun, 29 Dec 2024 14:38:25 +0100 Message-ID: <20241229133836.1194272-4-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 XFS will use it to calculate CRC of written data. Signed-off-by: Andrey Albershteyn --- fs/iomap/buffered-io.c | 4 ++++ include/linux/iomap.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 93da48ec5801..d6231f4f78d9 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1651,6 +1651,8 @@ iomap_ioend_can_merge(struct iomap_ioend *ioend, struct iomap_ioend *next) */ if (ioend->io_sector + (ioend->io_size >> 9) != next->io_sector) return false; + if (ioend->io_flags & IOMAP_F_NO_MERGE) + return false; return true; } @@ -1782,6 +1784,8 @@ static bool iomap_can_add_to_ioend(struct iomap_writepage_ctx *wpc, loff_t pos) */ if (wpc->nr_folios >= IOEND_BATCH_SIZE) return false; + if (wpc->iomap.flags & IOMAP_F_NO_MERGE) + return false; return true; } diff --git a/include/linux/iomap.h b/include/linux/iomap.h index f089969e4716..261772431fae 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -87,6 +87,8 @@ struct vm_fault; * Flags from 0x1000 up are for file system specific usage: */ #define IOMAP_F_PRIVATE (1U << 12) +/* No ioend merges for this operation */ +#define IOMAP_F_NO_MERGE (1U << 13) /* From patchwork Sun Dec 29 13:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922684 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 354B91531C8 for ; Sun, 29 Dec 2024 13:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479541; cv=none; b=Cy1aV5WH31gSxrJvmojLhGeVpAPYT7+M61DeReSD7gfn9ys0sqeYHGuvDy7+EG8JofL0H2j7tAsQhvAeVUOiqHeULPPXLjF60/jHpMCriiaXMEhivYz+eM2Uum1C5PvdYSaIbFwjVeSOwJ0NYr1mZjNpSOjVGjNi6AI0zYLEtmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479541; c=relaxed/simple; bh=KqjsI219C6GjkrjMjjigvRewv+6ofD6AgBkRPmS6qvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JRTyUXG73zNGy51NVFo4HWvQGdHBPI2ooUDiangkDU9YlEZpMzhttC0bNQt1ShoCAhYLfjLBPxylqw3eJC542cGd8nDbFomzv6ha0Q1S4BWAQ6Hv87+ZGmQq0ZOexZwC2f6KM7adH9oLpEXn5sxXAIm7klHD/s36qaeV6mUYEhM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=S2q534H1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="S2q534H1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479539; h=from:from:reply-to:subject:subject: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=X5pubKZOCFDh6mOTbFWYj1+wMeYj2AkCLgniK7fmSb0=; b=S2q534H1cOPZpzynjCdKZZLqGJJt/eNytvGd9BYYoWUfVwLDzCfpqLTvvMeT4hnz2CLEuQ gTLfKLaqLrfLDViY2L0K2yPVXTNTl1YZ6x8PNQqvOGmLdDcvt5eZfES/3dJFNLYfKjNpdX AQ+vFqp5tPz9QXhy23iO9H1w+d2lz5Q= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-468-Ca_8u_r-PhKqt84Znf5FKQ-1; Sun, 29 Dec 2024 08:38:57 -0500 X-MC-Unique: Ca_8u_r-PhKqt84Znf5FKQ-1 X-Mimecast-MFC-AGG-ID: Ca_8u_r-PhKqt84Znf5FKQ Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4359eb032c9so67625295e9.2 for ; Sun, 29 Dec 2024 05:38:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479535; x=1736084335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X5pubKZOCFDh6mOTbFWYj1+wMeYj2AkCLgniK7fmSb0=; b=ti2vpws8X/ObwPgajVKMK0pydvmuHJ+LYB6VM/YHqaZAKOMfsbSbfkqbw7zJ8379/c W2JoBFURLsuJaRDNIDznmDaLTR95cbGCxdqQPJKKcB845+f2ZhnvBsEwNKJcEGz5NWLB T09KxrAcmD+uTE35LUet7XoKf/criUTrJ66+oO8ZjJVb8B97yFPfFhBJ7zV6yHxYkcKE smOMTZ5bRpMiU4KXw/Qler7DOt3YxKl1uxQHunuPV6RLIs8/6QOUZfDSxEAgVDiTkeVS hOEJGWdSiRpBlOaDJBhMdjLNz6riC1rZeWYNXRi0MCNvmaefJPRhZiCPDId+t/w0chlq DxBA== X-Gm-Message-State: AOJu0YzfFuPH5jMhSnrtJob5+CmigJh1QCcwgpSbd9wMbKdcWh1P6cRM DTRhPWw6ATuz/QUcFyt8lKBkM0W27NTvqJu5C+aRKKm0FchxsEXpjtyVw0umkhC14yZv65/ZF0C 1ss7BHsIJGsnaAd2nyctwX4RSUEWvgnsBNQjnt6fx9j288FuykR9ND03uxio9IoG7EuSnU3qO3p ipVcthFOkJtkT2rmVkdH8IahaZIywvEvVELj72Pz4t X-Gm-Gg: ASbGnctvzKCzsLK9QkPOYxoPIAkPCRPJLGLofJu81s2xBL/FjPiXtTs4TPqCzABCoJN sDh5gMO1qTDw4AvS9u+UKmAFN2YaTmJsqWE3PlGqxA+bqzzqs5WRjN+JfdoqjdDdkEpQL0VX2wb 0vG3hjNMvp7/kPfEIH+eP+rPWdJ+cho2RWPAQfv18BGf+rV203lGTL40i51lRD70eWkYB+Hp6O7 7lxVILv46FOk416Jh+ts8rZs95TxCrYr+hMXIM38JQS8dV64gdtnDFVsDFuavQ2BzOb+wxGDxSz gtMgR71wzXdPjzQ= X-Received: by 2002:a05:600c:3ca1:b0:434:ff25:199f with SMTP id 5b1f17b1804b1-43668b480dbmr253567025e9.26.1735479535142; Sun, 29 Dec 2024 05:38:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfYQFaKwIKOfgY9IN2VZZmVUkG5U6ac/rvBSPyLTeN8sxNqOxWlXduq7Rq7AJuWExc6rR5SQ== X-Received: by 2002:a05:600c:3ca1:b0:434:ff25:199f with SMTP id 5b1f17b1804b1-43668b480dbmr253566855e9.26.1735479534734; Sun, 29 Dec 2024 05:38:54 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:38:52 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 04/14] xfs: add incompat directly mapped xattr flag Date: Sun, 29 Dec 2024 14:38:26 +0100 Message-ID: <20241229133836.1194272-5-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andrey Albershteyn Add directly mapped xattr through page cache incompatibility flag as this changes on-disk format of remote extended attributes (xfs_attr3_rmt_hdr is gone and xfs_attr_leaf_name_remote gains CRC). Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_format.h | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 4d47a3e723aa..154458d72bc6 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -395,6 +395,7 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_EXCHRANGE (1 << 6) /* exchangerange supported */ #define XFS_SB_FEAT_INCOMPAT_PARENT (1 << 7) /* parent pointers */ #define XFS_SB_FEAT_INCOMPAT_METADIR (1 << 8) /* metadata dir tree */ +#define XFS_SB_FEAT_INCOMPAT_DXATTR (1 << 9) /* directly mapped xattrs */ #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE | \ XFS_SB_FEAT_INCOMPAT_SPINODES | \ From patchwork Sun Dec 29 13:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922686 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 28A8117BEBF for ; Sun, 29 Dec 2024 13:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479542; cv=none; b=TJPtKhqM7HWhYKnu2aKK9jf4XqKrmztj0eqVqxraV4sKYVN1XJ/I+ufczAILDqIxUx6dS5mXr17Lls829vcy4FRiDs98+r9hPxNL+jx7J9J9s7+y1AJ/IwvkiVE366msoofX6S3NP0jk2wdVcZbKIT8oi6lbXIA3vgJsulR3GGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479542; c=relaxed/simple; bh=xNhY9/C5LZaTSsQ7tsRDvj8heywUEY06y6VgVbvIwfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sPok5sBEYn95mlyH2rR5LFSasSw1ztO9UyS2jqljfZ9cn7rUIf/tDybJuPEDKedrHWuPlsR/1J1T8+omyDo/SqAi36oyvE0jXd1jqR44jREAgqDPKYiP6D/q4NADRBnE36zh+8qLHgxHcA1cY8TaAIdHyPSPL7qnEq0SAUiLBM0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=A8ep/9Tb; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A8ep/9Tb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479540; h=from:from:reply-to:subject:subject: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=Sc4xU01mk/3qZsFQGDaB37qCPIwdDLKQZ4wD3ATLNsQ=; b=A8ep/9TbOIIwhMuw6MtKTYr50aS/xV65nSr4DH5jY0N8tuGSBIpHHyZz+XizVIS0Pur4cA gxOAc9OCUEe3aedcudtnltNhSI5cX4UYUAegl8fQPvF+WLUaEAN36l1fGguBOBtmZLwtja DhfcUbNYjStU2G9Poh3SP/o+6Ia/hLc= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-472-y2Bf4pD0OCawLKBLDR93Mw-1; Sun, 29 Dec 2024 08:38:58 -0500 X-MC-Unique: y2Bf4pD0OCawLKBLDR93Mw-1 X-Mimecast-MFC-AGG-ID: y2Bf4pD0OCawLKBLDR93Mw Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4361c040ba8so10048495e9.1 for ; Sun, 29 Dec 2024 05:38:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479536; x=1736084336; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sc4xU01mk/3qZsFQGDaB37qCPIwdDLKQZ4wD3ATLNsQ=; b=heJj51QzeOQFtRSbai+r2OlPlems19+oG/JjJzs5YEbahkfdWIH7SI04KmXAsSiK2W 6UtKU+1nNqcNYDWVZuwUuckODygDwou1rKOhmFzkFlXjjTccNYhu+TGrVVeTxOBTK0D8 cEkN1Ht52QjTG+P8n/tS4QqaFsext3M21tOuqA0gSxS+RtUbF10fH38/XoiDAXhYRsiX Pd4+RLd3EGNRHuzOaWbnL4KnHn96sAI8fSgTfyZbHETB9PrdX6A8mcuot8pXsTKIKyZ6 KIusD82pPyobjgnGxcS0cn8wawcItxf8tqDSVEa7joxi3mxE1iIO0rytYCJU0APIpP78 m/Tg== X-Gm-Message-State: AOJu0YypD3DdlZK6uEBD4AFVe3L329Dk5Sq6uT18p9SVj/FYFLLe/vkY cLjnt0GOi1ATr2a5Lw9XKP+Gq9/mJTKOpBt2pV6nsgzoN8zDORUvKcfO8G1EDo8Se0soR8Ki9dD RraeGwMzXogwfP7/+QdyG5AecigFM6EpTHX/bERDRfTrZP5HOQZ1XFGAz1B85W/uedYshSFAjUp KmxAuOaNyZRLPMrto+88OB+nqo/T2SDGLEmFVLCzmP X-Gm-Gg: ASbGncujivGdpLvnK/JqFAHr99lgPKUbBxRwphUSX64wLYEbABw+bmAy19wpb1fHrEi CjJGayox1IvmMCCdUkYiqyitFvn1IVbMJW2RWv/SySEIS72sJUeBzBDum6TDqHoDw9Gsg64I1Bj WPxbb/9PLECVVglB9sVMpM2l4slqXirUpHEgUW4oBcyzASirK2CD1GI9kxm2vtPjH1VNjv/yU07 Gl8LodGk5rHKlrwF3llWT0KwNnkf7L4VeECOGmbG8csoFemISTfGQXj6ILz93R7Pwvf5CvVGLll DGB37YUXrXrYWzI= X-Received: by 2002:a05:600c:5488:b0:436:5165:f21f with SMTP id 5b1f17b1804b1-43668b498ddmr251886625e9.26.1735479535941; Sun, 29 Dec 2024 05:38:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcYgekaz4XDyXDT/gJ/qncBqDCxQr7ciuBAr7eyoCG3hWGJZ5vpCN1jHOdGaUeJpaeTOHGNw== X-Received: by 2002:a05:600c:5488:b0:436:5165:f21f with SMTP id 5b1f17b1804b1-43668b498ddmr251886495e9.26.1735479535548; Sun, 29 Dec 2024 05:38:55 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:38:55 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 05/14] libxfs: add xfs_calc_chsum() Date: Sun, 29 Dec 2024 14:38:27 +0100 Message-ID: <20241229133836.1194272-6-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andrey Albershteyn Calculate CRC of the buffer which will not be placed in this same buffer (common case for all other xfs_cksum.h uses). Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_cksum.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/xfs/libxfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h index 999a290cfd72..90884ed0ef23 100644 --- a/fs/xfs/libxfs/xfs_cksum.h +++ b/fs/xfs/libxfs/xfs_cksum.h @@ -79,4 +79,16 @@ xfs_verify_cksum(char *buffer, size_t length, unsigned long cksum_offset) return *(__le32 *)(buffer + cksum_offset) == xfs_end_cksum(crc); } +/* + * Helper to calculate the checksum of a buffer which is outside of the buffer + */ +static inline uint32_t +xfs_calc_cksum(char *buffer, size_t length, uint32_t *dst) +{ + uint32_t crc = crc32c(XFS_CRC_SEED, buffer, length); + if (dst) + *dst = crc; + return crc; +} + #endif /* _XFS_CKSUM_H */ From patchwork Sun Dec 29 13:38:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922687 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 6F7C617C20F for ; Sun, 29 Dec 2024 13:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479544; cv=none; b=Zzt2LmnzWQY9z3LQuIGjYMeQqtX13gqp+cguqBzJn4pcRDDJ1S3oS3Qv+uESVdDhilWPJfu9pjnlXpMc7n4gV4oQyvhDJcWfnNcypK+QhXJu9ckl5S/B7yd9UTv0okpJJKgsJaxtL6coBcM7MXTdAvMuH8UloL5XrOoaPbfneZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479544; c=relaxed/simple; bh=yNMK+cXUUFlYsky9xtRclRAoO+joiKNTh1Amgr5jHw0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FGVaw8IK3BAizpcb/7FOVagPy40iH7GXbNdTNXn5wUcQKKhhaEIee4ImOO7d4pQzAUce4ZTJ2ppULtVTKQYjgbOM7f6O53e1aVKPZDOcvcJWDpSw6Nk5VMgT+y/U+GFRGWRFlv0OU0SNk7QjAHTPf7/QMxfnnrTmTahRU32gavY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TD3r57gl; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TD3r57gl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479541; h=from:from:reply-to:subject:subject: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=sykCjcocIlR0khpsmKYVwfZ8dpYtCo1kMYbbxSnV/zU=; b=TD3r57gloxrfN2kosAgoAcn2HBozQs3+uUCcgGNrdKsQez2G/prb/Dr+/vzl0u6G0bCb0u vfezynPGUQwUqt9evXhla0OrP87GqOEajTbx9UWB/kSwoGIR2Ik+HvbB2/UgEJJKCK+jLT uZ2UjenchETl8nnAnd8s3vA2lTn5MuA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-379-zuCmgeDhNIqAysg-Zp6HpQ-1; Sun, 29 Dec 2024 08:39:00 -0500 X-MC-Unique: zuCmgeDhNIqAysg-Zp6HpQ-1 X-Mimecast-MFC-AGG-ID: zuCmgeDhNIqAysg-Zp6HpQ Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4361ac8b25fso48579525e9.2 for ; Sun, 29 Dec 2024 05:39:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479539; x=1736084339; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sykCjcocIlR0khpsmKYVwfZ8dpYtCo1kMYbbxSnV/zU=; b=nQGHzvFeLaXHER2t7vm1o1IVM000tJggY58vPO7iWFu1sSsMzgzNHWOCAqbDcPhWp0 7gPt/bpgfnJWLNm58CS/R6gRUwsfTm2H/qke/FN78t84AdAXiVUXWo71uuxfkyOKT/Uq 4TgLrRKiovckRj601GbgKxxc58iJ2NmHMuGxNZbAoG8J7uolecylBRxrRBb0m8zQ4LYO 8457cGWni6k7LPxxPUKw8mjhkwMSxq4iU2BaSFwoRzR9bl1uRcZXxJQseE9YcpBxFUAJ yhX6kZVPHiAUmk3HqU3JngN3sSbruSEAu8hHZGnNc+h8fHDPvHGr+BlfJTDUM44hU6BS M6iw== X-Gm-Message-State: AOJu0YzNys1QJE6iTHw8iT7iQynrjFUrisvZCCcT3/pFpb3e5nhKZz1Y ICB8PR2vorExPAdaDlbGuBxiJl0oPwVFNflsHEoImEwixrtvcKVfRVWls6r6B9rEorUb3yncIL6 q1rJugE6LYFm+2kiDzk1kSuBkl5l0ozQIHP6/Li113OZksZOU0S7ak8v8PIfhLeysG1SMrr/Kg+ Ncq/SL9w57o+tthrjRx7BLVn4wDTpbhMMR6Dw9teFj X-Gm-Gg: ASbGncslo29Avr4Q2826dUP9lrMV/WVHxiWVHIUHLI/cQx10O3dvq0fQzulU3+KIDTY 4ZkXce8mKvTYxJMrucv0Z802sWASPtRi/B7UoMlOpcHE5f0efTEKCEEqy5p2w0Um8jn1pSRsbMT +uGrOg6ksgq52uB0S8CxXI0Rum9hwcygCqr8OMkCH3DkG+9dyW6W9z99t4sdMhaZHH/lkcgohdG 52rzPRyf0k0aqVIfMy6lwd8ymG1XW737MnuLw8QuOATCWcsKvhhLMVmLTSxc5kGeH9KgAcAEny7 zOJ/ezox6jDFyuk= X-Received: by 2002:a05:600c:1994:b0:435:306:e5dd with SMTP id 5b1f17b1804b1-43668b5dfaamr262071935e9.22.1735479538709; Sun, 29 Dec 2024 05:38:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbjuoOvXjbOiBKJcvvfFziJXvofNI6P7m1VXl0j+iKi1xAr4xpA5oXMZPEBLw8+2twrgZIoA== X-Received: by 2002:a05:600c:1994:b0:435:306:e5dd with SMTP id 5b1f17b1804b1-43668b5dfaamr262071755e9.22.1735479538113; Sun, 29 Dec 2024 05:38:58 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:38:55 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 06/14] libxfs: pass xfs_sb to xfs_attr3_leaf_name_remote() Date: Sun, 29 Dec 2024 14:38:28 +0100 Message-ID: <20241229133836.1194272-7-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This will be needed to check with feature flags if new format of xfs_attr_leaf_name_remote is in use. This commit just changes signature of xfs_attr3_leaf_name_remote() by adding xfs_sb. Superblock will be used in later commit. Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_attr_leaf.c | 80 +++++++++++++++++++++++------------ fs/xfs/libxfs/xfs_da_format.h | 5 ++- fs/xfs/scrub/attr.c | 2 +- fs/xfs/scrub/attr_repair.c | 3 +- fs/xfs/scrub/listxattr.c | 3 +- fs/xfs/xfs_attr_inactive.c | 2 +- fs/xfs/xfs_attr_list.c | 3 +- 7 files changed, 65 insertions(+), 33 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index fddb55605e0c..c657638efe04 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -73,7 +73,11 @@ STATIC void xfs_attr3_leaf_moveents(struct xfs_da_args *args, struct xfs_attr_leafblock *dst_leaf, struct xfs_attr3_icleaf_hdr *dst_ichdr, int dst_start, int move_count); -STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index); +STATIC int +xfs_attr_leaf_entsize( + struct xfs_mount *mp, + xfs_attr_leafblock_t *leaf, + int index); /* * attr3 block 'firstused' conversion helpers. @@ -274,7 +278,7 @@ xfs_attr3_leaf_verify_entry( if (lentry->namelen == 0) return __this_address; } else { - rentry = xfs_attr3_leaf_name_remote(leaf, idx); + rentry = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, idx); namesize = xfs_attr_leaf_entsize_remote(rentry->namelen); name_end = (char *)rentry + namesize; if (rentry->namelen == 0) @@ -1560,7 +1564,8 @@ xfs_attr3_leaf_add_work( memcpy((char *)&name_loc->nameval[args->namelen], args->value, be16_to_cpu(name_loc->valuelen)); } else { - name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, + args->index); name_rmt->namelen = args->namelen; memcpy((char *)name_rmt->name, args->name, args->namelen); entry->flags |= XFS_ATTR_INCOMPLETE; @@ -1571,9 +1576,10 @@ xfs_attr3_leaf_add_work( args->rmtblkcnt = xfs_attr3_rmt_blocks(mp, args->valuelen); args->rmtvaluelen = args->valuelen; } - xfs_trans_log_buf(args->trans, bp, - XFS_DA_LOGRANGE(leaf, xfs_attr3_leaf_name(leaf, args->index), - xfs_attr_leaf_entsize(leaf, args->index))); + xfs_trans_log_buf( + args->trans, bp, + XFS_DA_LOGRANGE(leaf, xfs_attr3_leaf_name(leaf, args->index), + xfs_attr_leaf_entsize(mp, leaf, args->index))); /* * Update the control info for this leaf node @@ -1594,7 +1600,7 @@ xfs_attr3_leaf_add_work( sizeof(xfs_attr_leaf_entry_t)); } } - ichdr->usedbytes += xfs_attr_leaf_entsize(leaf, args->index); + ichdr->usedbytes += xfs_attr_leaf_entsize(mp, leaf, args->index); } /* @@ -1910,6 +1916,7 @@ xfs_attr3_leaf_figure_balance( struct xfs_attr_leafblock *leaf1 = blk1->bp->b_addr; struct xfs_attr_leafblock *leaf2 = blk2->bp->b_addr; struct xfs_attr_leaf_entry *entry; + struct xfs_mount *mp = state->mp; int count; int max; int index; @@ -1958,8 +1965,8 @@ xfs_attr3_leaf_figure_balance( /* * Figure out if next leaf entry would be too much. */ - tmp = totallen + sizeof(*entry) + xfs_attr_leaf_entsize(leaf1, - index); + tmp = totallen + sizeof(*entry) + + xfs_attr_leaf_entsize(mp, leaf1, index); if (XFS_ATTR_ABS(half - tmp) > lastdelta) break; lastdelta = XFS_ATTR_ABS(half - tmp); @@ -2132,6 +2139,7 @@ xfs_attr3_leaf_remove( struct xfs_attr_leafblock *leaf; struct xfs_attr3_icleaf_hdr ichdr; struct xfs_attr_leaf_entry *entry; + struct xfs_mount *mp = args->dp->i_mount; int before; int after; int smallest; @@ -2166,7 +2174,7 @@ xfs_attr3_leaf_remove( tmp = ichdr.freemap[0].size; before = after = -1; smallest = XFS_ATTR_LEAF_MAPSIZE - 1; - entsize = xfs_attr_leaf_entsize(leaf, args->index); + entsize = xfs_attr_leaf_entsize(mp, leaf, args->index); for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) { ASSERT(ichdr.freemap[i].base < args->geo->blksize); ASSERT(ichdr.freemap[i].size < args->geo->blksize); @@ -2414,6 +2422,7 @@ xfs_attr3_leaf_lookup_int( struct xfs_attr_leaf_entry *entries; struct xfs_attr_leaf_name_local *name_loc; struct xfs_attr_leaf_name_remote *name_rmt; + struct xfs_mount *mp = args->dp->i_mount; xfs_dahash_t hashval; int probe; int span; @@ -2492,7 +2501,8 @@ xfs_attr3_leaf_lookup_int( } else { unsigned int valuelen; - name_rmt = xfs_attr3_leaf_name_remote(leaf, probe); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, + probe); valuelen = be32_to_cpu(name_rmt->valuelen); if (!xfs_attr_match(args, entry->flags, name_rmt->name, name_rmt->namelen, NULL, valuelen)) @@ -2528,6 +2538,7 @@ xfs_attr3_leaf_getvalue( struct xfs_attr_leaf_entry *entry; struct xfs_attr_leaf_name_local *name_loc; struct xfs_attr_leaf_name_remote *name_rmt; + struct xfs_mount *mp = args->dp->i_mount; leaf = bp->b_addr; xfs_attr3_leaf_hdr_from_disk(args->geo, &ichdr, leaf); @@ -2544,7 +2555,7 @@ xfs_attr3_leaf_getvalue( be16_to_cpu(name_loc->valuelen)); } - name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, args->index); ASSERT(name_rmt->namelen == args->namelen); ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0); args->rmtvaluelen = be32_to_cpu(name_rmt->valuelen); @@ -2576,6 +2587,7 @@ xfs_attr3_leaf_moveents( { struct xfs_attr_leaf_entry *entry_s; struct xfs_attr_leaf_entry *entry_d; + struct xfs_mount *mp = args->dp->i_mount; int desti; int tmp; int i; @@ -2624,7 +2636,7 @@ xfs_attr3_leaf_moveents( desti = start_d; for (i = 0; i < count; entry_s++, entry_d++, desti++, i++) { ASSERT(be16_to_cpu(entry_s->nameidx) >= ichdr_s->firstused); - tmp = xfs_attr_leaf_entsize(leaf_s, start_s + i); + tmp = xfs_attr_leaf_entsize(mp, leaf_s, start_s + i); #ifdef GROT /* * Code to drop INCOMPLETE entries. Difficult to use as we @@ -2730,12 +2742,15 @@ xfs_attr_leaf_lasthash( * (whether local or remote only calculate bytes in this block). */ STATIC int -xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index) +xfs_attr_leaf_entsize( + struct xfs_mount *mp, + xfs_attr_leafblock_t *leaf, + int index) { - struct xfs_attr_leaf_entry *entries; - xfs_attr_leaf_name_local_t *name_loc; - xfs_attr_leaf_name_remote_t *name_rmt; - int size; + struct xfs_attr_leaf_entry *entries; + xfs_attr_leaf_name_local_t *name_loc; + xfs_attr_leaf_name_remote_t *name_rmt; + int size; entries = xfs_attr3_leaf_entryp(leaf); if (entries[index].flags & XFS_ATTR_LOCAL) { @@ -2743,7 +2758,7 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index) size = xfs_attr_leaf_entsize_local(name_loc->namelen, be16_to_cpu(name_loc->valuelen)); } else { - name_rmt = xfs_attr3_leaf_name_remote(leaf, index); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, index); size = xfs_attr_leaf_entsize_remote(name_rmt->namelen); } return size; @@ -2789,6 +2804,7 @@ xfs_attr3_leaf_clearflag( struct xfs_attr_leaf_entry *entry; struct xfs_attr_leaf_name_remote *name_rmt; struct xfs_buf *bp; + struct xfs_mount *mp = args->dp->i_mount; int error; #ifdef DEBUG struct xfs_attr3_icleaf_hdr ichdr; @@ -2820,7 +2836,8 @@ xfs_attr3_leaf_clearflag( namelen = name_loc->namelen; name = (char *)name_loc->nameval; } else { - name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, + args->index); namelen = name_rmt->namelen; name = (char *)name_rmt->name; } @@ -2835,11 +2852,13 @@ xfs_attr3_leaf_clearflag( if (args->rmtblkno) { ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0); - name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, + args->index); name_rmt->valueblk = cpu_to_be32(args->rmtblkno); name_rmt->valuelen = cpu_to_be32(args->rmtvaluelen); xfs_trans_log_buf(args->trans, bp, - XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); + XFS_DA_LOGRANGE(leaf, name_rmt, + sizeof(*name_rmt))); } return 0; @@ -2856,6 +2875,7 @@ xfs_attr3_leaf_setflag( struct xfs_attr_leaf_entry *entry; struct xfs_attr_leaf_name_remote *name_rmt; struct xfs_buf *bp; + struct xfs_mount *mp = args->dp->i_mount; int error; #ifdef DEBUG struct xfs_attr3_icleaf_hdr ichdr; @@ -2884,7 +2904,8 @@ xfs_attr3_leaf_setflag( xfs_trans_log_buf(args->trans, bp, XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); if ((entry->flags & XFS_ATTR_LOCAL) == 0) { - name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, + args->index); name_rmt->valueblk = 0; name_rmt->valuelen = 0; xfs_trans_log_buf(args->trans, bp, @@ -2912,6 +2933,7 @@ xfs_attr3_leaf_flipflags( struct xfs_attr_leaf_name_remote *name_rmt; struct xfs_buf *bp1; struct xfs_buf *bp2; + struct xfs_mount *mp = args->dp->i_mount; int error; #ifdef DEBUG struct xfs_attr3_icleaf_hdr ichdr1; @@ -2963,7 +2985,8 @@ xfs_attr3_leaf_flipflags( namelen1 = name_loc->namelen; name1 = (char *)name_loc->nameval; } else { - name_rmt = xfs_attr3_leaf_name_remote(leaf1, args->index); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf1, + args->index); namelen1 = name_rmt->namelen; name1 = (char *)name_rmt->name; } @@ -2972,7 +2995,8 @@ xfs_attr3_leaf_flipflags( namelen2 = name_loc->namelen; name2 = (char *)name_loc->nameval; } else { - name_rmt = xfs_attr3_leaf_name_remote(leaf2, args->index2); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf2, + args->index2); namelen2 = name_rmt->namelen; name2 = (char *)name_rmt->name; } @@ -2989,7 +3013,8 @@ xfs_attr3_leaf_flipflags( XFS_DA_LOGRANGE(leaf1, entry1, sizeof(*entry1))); if (args->rmtblkno) { ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0); - name_rmt = xfs_attr3_leaf_name_remote(leaf1, args->index); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf1, + args->index); name_rmt->valueblk = cpu_to_be32(args->rmtblkno); name_rmt->valuelen = cpu_to_be32(args->rmtvaluelen); xfs_trans_log_buf(args->trans, bp1, @@ -3000,7 +3025,8 @@ xfs_attr3_leaf_flipflags( xfs_trans_log_buf(args->trans, bp2, XFS_DA_LOGRANGE(leaf2, entry2, sizeof(*entry2))); if ((entry2->flags & XFS_ATTR_LOCAL) == 0) { - name_rmt = xfs_attr3_leaf_name_remote(leaf2, args->index2); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf2, + args->index2); name_rmt->valueblk = 0; name_rmt->valuelen = 0; xfs_trans_log_buf(args->trans, bp2, diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index 86de99e2f757..afc25b6d805e 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -773,7 +773,10 @@ xfs_attr3_leaf_name(xfs_attr_leafblock_t *leafp, int idx) } static inline xfs_attr_leaf_name_remote_t * -xfs_attr3_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx) +xfs_attr3_leaf_name_remote( + struct xfs_sb *sb, + xfs_attr_leafblock_t *leafp, + int idx) { return (xfs_attr_leaf_name_remote_t *)xfs_attr3_leaf_name(leafp, idx); } diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 708334f9b2bd..d911cf9cad20 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -361,7 +361,7 @@ xchk_xattr_entry( if (lentry->namelen == 0) xchk_da_set_corrupt(ds, level); } else { - rentry = xfs_attr3_leaf_name_remote(leaf, idx); + rentry = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, idx); namesize = xfs_attr_leaf_entsize_remote(rentry->namelen); name_end = (char *)rentry + namesize; if (rentry->namelen == 0 || rentry->valueblk == 0) diff --git a/fs/xfs/scrub/attr_repair.c b/fs/xfs/scrub/attr_repair.c index c7eb94069caf..2a8e70f45361 100644 --- a/fs/xfs/scrub/attr_repair.c +++ b/fs/xfs/scrub/attr_repair.c @@ -436,7 +436,8 @@ xrep_xattr_recover_leaf( error = xrep_xattr_salvage_local_attr(rx, ent, nameidx, buf_end, lentry); } else { - rentry = xfs_attr3_leaf_name_remote(leaf, i); + rentry = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, + i); error = xrep_xattr_salvage_remote_attr(rx, ent, nameidx, buf_end, rentry, i, bp); } diff --git a/fs/xfs/scrub/listxattr.c b/fs/xfs/scrub/listxattr.c index 256ff7700c94..70ec6d2ff907 100644 --- a/fs/xfs/scrub/listxattr.c +++ b/fs/xfs/scrub/listxattr.c @@ -84,7 +84,8 @@ xchk_xattr_walk_leaf_entries( } else { struct xfs_attr_leaf_name_remote *name_rmt; - name_rmt = xfs_attr3_leaf_name_remote(leaf, i); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, + i); name = name_rmt->name; namelen = name_rmt->namelen; value = NULL; diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c index 24fb12986a56..2495ff76acec 100644 --- a/fs/xfs/xfs_attr_inactive.c +++ b/fs/xfs/xfs_attr_inactive.c @@ -106,7 +106,7 @@ xfs_attr3_leaf_inactive( if (!entry->nameidx || (entry->flags & XFS_ATTR_LOCAL)) continue; - name_rmt = xfs_attr3_leaf_name_remote(leaf, i); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, i); if (!name_rmt->valueblk) continue; diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 379b48d015d2..4388443e2db7 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -506,7 +506,8 @@ xfs_attr3_leaf_list_int( } else { xfs_attr_leaf_name_remote_t *name_rmt; - name_rmt = xfs_attr3_leaf_name_remote(leaf, i); + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, + i); name = name_rmt->name; namelen = name_rmt->namelen; value = NULL; From patchwork Sun Dec 29 13:38:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922688 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 BC42F15820C for ; Sun, 29 Dec 2024 13:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479545; cv=none; b=ingF7L153jgmvmjg4KLeaWOLUKAaIq9HCu0ZhnMMSZfIIxyZuxDkgcGE2/P2um7QA8GFWSrzyKt1XZQMnCm4uU6SnKW6NrHIXmVGMuCrQPhleOkzmHZFV1vqkNR+8NBfM62RP8Id/U5XFa6e13JeubEyPn+7yCAo/B64tAvItlk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479545; c=relaxed/simple; bh=yB8EB0fN1wRruFNo1C107zY4O9o5wnt/8yS/iA3u+Mg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GIqrjIrCxV2oDtIyFtZQwwU39TsZDQN7HugODDT1Q3jBLAybCREb7zPNzqQzb2omU32QPeplIXvdseJ3SoAvJ3wCJAAT74p0dQ1DdGyNUx5GZ2jv/Pf0zkzSoHS2uXOwfdRJpenMTsJNTkEhsHTggd2VH/r4zWYZqF5hYF3UJe4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=cIg32JTt; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cIg32JTt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479542; h=from:from:reply-to:subject:subject: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=Cl5eoui1m9xBBlR6Fd0q3sI82yIiCIQr7B7+qi3Qmd0=; b=cIg32JTtsksEvH5AnpRCBippGFgFVdB+1szvavD4VckE+Q1RLOrO7GXtt0ejSQCSA4Pv4g r/HfuhNPKvDUWI8OHsB4c4n+QTyNbrLlg1+BcawJBP3f+wWUdvP8TlsTDXGf1RuHT3phtu pMq68T9STlmAJ1Mj+ulsrM1uH5Ix5y0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-425-t3Ek5ujGNHO3PGS3bwCBtA-1; Sun, 29 Dec 2024 08:39:01 -0500 X-MC-Unique: t3Ek5ujGNHO3PGS3bwCBtA-1 X-Mimecast-MFC-AGG-ID: t3Ek5ujGNHO3PGS3bwCBtA Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4361efc9d1fso63262385e9.2 for ; Sun, 29 Dec 2024 05:39:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479539; x=1736084339; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cl5eoui1m9xBBlR6Fd0q3sI82yIiCIQr7B7+qi3Qmd0=; b=TqBzs1cjwV4oCVrG3qTfeAqgai5YLNboAYpt6vwXeBiElE8uF8n7nSXx6k5K1/tU8a /ZgMYFgtrE8waRtUQ2MW6IPLChoN9Cnz8GuhvjUzOc5wcHP8i61v/pwytp7hbtINeJZg UjHb3r/HwAbJ6ZfKbZZR8FPDQE3URWYaBH/PVTcHypQJYDVh0Xta1T9Vj1lF9SQc2qNA 9z3HS7VVgi9azIeEAQwXe053ti3G+JCJ9dF0Vuu3evtrgj5EZkiDVHEZMN2gY4aThrmX Bipf2GzGwugo5G5HLm4oB/RJPdZg3WFMgx1t0aClBsO3w5KQIGzOJXExopHtP40EYGfW CckQ== X-Gm-Message-State: AOJu0YxgG9t5SMMUd253YXluJDolnYLL3nNV38MWw4D0GAgKJiK/cC0k OeM85En08Ts//LexmNDD+iF4rLyFqVpPMGImsF0IChUkPWKHzc5y5u3SuWq3PJ5VvCWeKLo3aSD 6P703EujcqgxodiZVvuB9NNnfJG5Bqb4zqsVXnLyIAGPpyPjbdayNEZDCAj+qSjjk/Hfa7joQj1 pGw16dSd6CNF1qc0es0cWPn8IGFEUavvP/xCP9pibi X-Gm-Gg: ASbGncvjkosHL+2jpVAz9yyxOrgROPgfiHJstIibQmxZXZRbYuT9FfvKN9zOyYmJ4M2 NmciDwfCFdgQkXTBjA3a9g7w+q/qM6B9JRbJLU0u6pKzquVU0o8bCpfQYIC4mu+nfG9VYb7tFMi l1XXf0qMnFinV7TrE96xvJ9tpYuCYtaRkcuZ3FupacBq7QgT8TmuzXhoXfGMPTyKTdbzrdYfrYt t+9VovSYYQdE3E/ulFCUbjzY8ihx+9Z5Z+Ib1zNJkVAtsWJQs/6hNjEbF97FiFfwRhZU0jAOaBP eAaw4D3rlm7E+yA= X-Received: by 2002:a05:6000:2c8:b0:385:fb2c:6034 with SMTP id ffacd0b85a97d-38a223f830dmr27785531f8f.47.1735479539348; Sun, 29 Dec 2024 05:38:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsn59qw2xT/PqoXMyd2l1Hc9hWlAf4OMIuRFsPza5/Aqg5pAfN7+d0UhgyVJ4J4UUS9LOVTA== X-Received: by 2002:a05:6000:2c8:b0:385:fb2c:6034 with SMTP id ffacd0b85a97d-38a223f830dmr27785514f8f.47.1735479539006; Sun, 29 Dec 2024 05:38:59 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:38:58 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 07/14] xfs: introduce XFS_DA_OP_EMPTY Date: Sun, 29 Dec 2024 14:38:29 +0100 Message-ID: <20241229133836.1194272-8-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Allocate blocks but don't copy data into the attribute. Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_attr.c | 8 +++++--- fs/xfs/libxfs/xfs_da_btree.h | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 17875ad865f5..5060c266f776 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -642,9 +642,11 @@ xfs_attr_rmtval_alloc( goto out; } - error = xfs_attr_rmtval_set_value(args); - if (error) - return error; + if (!(args->op_flags & XFS_DA_OP_EMPTY)) { + error = xfs_attr_rmtval_set_value(args); + if (error) + return error; + } attr->xattri_dela_state = xfs_attr_complete_op(attr, ++attr->xattri_dela_state); diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index 354d5d65043e..2428a3a466cb 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -97,6 +97,7 @@ typedef struct xfs_da_args { #define XFS_DA_OP_CILOOKUP (1u << 4) /* lookup returns CI name if found */ #define XFS_DA_OP_RECOVERY (1u << 5) /* Log recovery operation */ #define XFS_DA_OP_LOGGED (1u << 6) /* Use intent items to track op */ +#define XFS_DA_OP_EMPTY (1u << 7) /* Don't copy any data but alloc blks */ #define XFS_DA_OP_FLAGS \ { XFS_DA_OP_JUSTCHECK, "JUSTCHECK" }, \ @@ -105,7 +106,8 @@ typedef struct xfs_da_args { { XFS_DA_OP_OKNOENT, "OKNOENT" }, \ { XFS_DA_OP_CILOOKUP, "CILOOKUP" }, \ { XFS_DA_OP_RECOVERY, "RECOVERY" }, \ - { XFS_DA_OP_LOGGED, "LOGGED" } + { XFS_DA_OP_LOGGED, "LOGGED" }, \ + { XFS_DA_OP_EMPTY, "EMPTY" } /* * Storage for holding state during Btree searches and split/join ops. From patchwork Sun Dec 29 13:38:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922689 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 5BD6B15B54A for ; Sun, 29 Dec 2024 13:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479546; cv=none; b=I3M+ow1XEk5s7qnz3AKkJH5hYp+9otv4WLAcBMPt5TQImQJUdtLDr3bXFLRXGLNK6jODIT6sczaHLYCpfIMfoi4YRgXMajlrRpEcv4sZFllMbzaNxQNGXX51zZxsAd1+m9Ipd3BdvNWNrpLsUajuOqxOBy72SJtGmjqVvRvq91E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479546; c=relaxed/simple; bh=i2Ne3GImbukVLxYXpQOeimEOzXEXSiKn9qwowxUDQDM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zmi/kWegQaEHEuhLQA3qp3yG5TbziJDdUTMRZWYmaXZa49l6lnJtfhh2ztzrvkhdegpV4js8VNGYTVeYeXnlvNIXVApKWmqu9uGlUMCVZ/XmRvoxqPUr0QYxQhVS6jcflp+DAunpuajUb8++Xli+sSYTZFe9ViR234hnqTprEr0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GnK7/BCH; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GnK7/BCH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479544; h=from:from:reply-to:subject:subject: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=U8AjF3VizkOa7g83PnPMwpedj+JUQeIKPqJB6UYbXeM=; b=GnK7/BCHIReDIfW7/HWJ8aZSLcN+v26lWmHc0fM/4EUJnkFuEaY4r0G/ajGAk9NbuU8i0T +4rY2puQWar0SqcJx+KULkkYksoKRUI+igPW0k7H9VC+pQKsTYH47U+PHqvWJhqsK6dq+H uxhi0tnWfL1RfHT25XEJNxWYRtGVDR8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-284-UT0-oJhgMl28AhUnhOSezQ-1; Sun, 29 Dec 2024 08:39:03 -0500 X-MC-Unique: UT0-oJhgMl28AhUnhOSezQ-1 X-Mimecast-MFC-AGG-ID: UT0-oJhgMl28AhUnhOSezQ Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-385dcadffebso4267210f8f.0 for ; Sun, 29 Dec 2024 05:39:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479541; x=1736084341; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U8AjF3VizkOa7g83PnPMwpedj+JUQeIKPqJB6UYbXeM=; b=DLAIW8SqbquuSpWgkxp1c3UtXRY1Hb4rqZsVfqryVmckqkMSK8ew18GRCfdzLtpNco n2VkDjaCJVvThAaKpfArbbFOBr9Z6pAazNsgWaYxbGLoEwvPF6yuFXLbqV+Cg5moanDX 0EExW3ElBAuPraRZ/nusIaaQVBQBH0fZ9xmFMZ11pWzXRri721S3n4rM0rYMNbO7Ot+k 86rxBoz3G6+jmhhF7UsmcUPFaTZzVngantO1QMkly5dZjF/naCiEKXz2EW6a2rJ7IsGh 2pYK0YhoCExLldBQYdnwpXOzrgkK57sizwupSVMwKYNqrNvOEukkgIkl0/C2RocntTWF AuBw== X-Gm-Message-State: AOJu0YyGFbqe6DxhEASMxgzHKPCS3tZ47pAlaZwHgeJf+KdM0wDMvCJW MNIyszRZe5DglbfXLxN+RizzuBr2cBBedO+1i+4MVdG4KQUpCvBajiTt88EMMXdTFKSZGrD+TTy NokNNsS/g0jlUf9msLvpKo3ll09s3c4Cz3HIKH/FBYU+9vBb2arrdh0+Gg5Rj3HJKyJqa+1YVqj qhMOjnVM1xo+SfNciAQMJgknD0DacpDxMzmiyyZtmZ X-Gm-Gg: ASbGnctWGa5ZsVS78Ai2UXwLA9gKtEFNlzxIZcpEY7Zji4jAusxE3CNblC4jZStO0sb H92xgqY/AnI8wZEn/yPL3Lx5eRtLU9sWzoU++WrBNNGKSUZmVJpyxbI5UwOA32A5JciN13HGYEW T+4p34CTXx2ouQwYK9bM5SUlIr9bgemsqZttcmUafgbhplIDLPzdrgMaIYhCFZ1OpMOAwJh/fTr ZFT+pmzr/K1qU2l1HFcbUiorQr0tr7dKO4S/xLO85M53SpRQyIESaQxXGE0/JYaLL91bnky57oU PpO8qlfNJ5jA6NI= X-Received: by 2002:a5d:47a5:0:b0:385:f677:8594 with SMTP id ffacd0b85a97d-38a223f5da3mr24374398f8f.43.1735479541203; Sun, 29 Dec 2024 05:39:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEb14NaaaQIpD9FA7qu1HWdNEg2ciH7s34nDpUfvIw5qCEs7dDm9OKKwRCPjnq2qdjywPyfg== X-Received: by 2002:a5d:47a5:0:b0:385:f677:8594 with SMTP id ffacd0b85a97d-38a223f5da3mr24374383f8f.43.1735479540895; Sun, 29 Dec 2024 05:39:00 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:38:59 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 08/14] xfs: introduce workqueue for post read processing Date: Sun, 29 Dec 2024 14:38:30 +0100 Message-ID: <20241229133836.1194272-9-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 With directly mapped attribute data we need to verify that attribute data corresponds to the CRC stored in da tree. This need to be done at IO completion. Add workqueue for read path work. Signed-off-by: Andrey Albershteyn --- fs/xfs/xfs_mount.h | 1 + fs/xfs/xfs_super.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index db9dade7d22a..d772d908ba3c 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -136,6 +136,7 @@ typedef struct xfs_mount { struct xfs_mru_cache *m_filestream; /* per-mount filestream data */ struct workqueue_struct *m_buf_workqueue; struct workqueue_struct *m_unwritten_workqueue; + struct workqueue_struct *m_postread_workqueue; struct workqueue_struct *m_reclaim_workqueue; struct workqueue_struct *m_sync_workqueue; struct workqueue_struct *m_blockgc_wq; diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 394fdf3bb535..4ab93adaab0c 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -559,6 +559,12 @@ xfs_init_mount_workqueues( if (!mp->m_unwritten_workqueue) goto out_destroy_buf; + mp->m_postread_workqueue = alloc_workqueue("xfs-pread/%s", + XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM), + 0, mp->m_super->s_id); + if (!mp->m_postread_workqueue) + goto out_destroy_postread; + mp->m_reclaim_workqueue = alloc_workqueue("xfs-reclaim/%s", XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM), 0, mp->m_super->s_id); @@ -592,6 +598,8 @@ xfs_init_mount_workqueues( destroy_workqueue(mp->m_reclaim_workqueue); out_destroy_unwritten: destroy_workqueue(mp->m_unwritten_workqueue); +out_destroy_postread: + destroy_workqueue(mp->m_postread_workqueue); out_destroy_buf: destroy_workqueue(mp->m_buf_workqueue); out: @@ -607,6 +615,7 @@ xfs_destroy_mount_workqueues( destroy_workqueue(mp->m_inodegc_wq); destroy_workqueue(mp->m_reclaim_workqueue); destroy_workqueue(mp->m_unwritten_workqueue); + destroy_workqueue(mp->m_postread_workqueue); destroy_workqueue(mp->m_buf_workqueue); } From patchwork Sun Dec 29 13:38:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922690 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 73BF317B50A for ; Sun, 29 Dec 2024 13:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479549; cv=none; b=Guo4fNPr7m4LvqvYxUpDvwxi0njreslL2fR1lDZCEhFKD80/FaTnqeJZppDaP8IVOs+XZoJoRiEzFegemtBtuEdDlMNhk/up4mVjadlXMnr223aPVjSvno7rLvUK1PKqzWQCDib9XMVwnCjFkrNWy/e0GgXrylJmsdOsgzuSRAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479549; c=relaxed/simple; bh=84rmwROxFNCB27hZX7A0P/DgwqtM6C41teUViZL4UAM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MA8R5LnL2CwMT1NuN2ZBXwUyJURrWidNwuUcAeXUn2EqfR2VDrw6JEhD5ZjE/gXyj3VkyO/y+CBVq/R9vgHQ8u10+Pv8J4GUQLtWnYD9/TRtidlsFPVqsPiJHdlR0ztkNtucwiV9t/yGILO/1JTf6zRwEMR3ZuxZSFpYQZUJ66Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DWlFOVOT; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DWlFOVOT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479545; h=from:from:reply-to:subject:subject: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=ewOKMuYK43WJG2ALaY5n3pXvxddbNuZFCxaX4PT5PsA=; b=DWlFOVOT6dSlk7OUQnxVgzczEM5tXM0M7w6v/EZvNQ4Hn+59AEzVdzqPrd/ovyks9HHk8f 0JXZN+DmNgUxdl5voG3gKJgGuK8eYUrtb0+KIQX+RqF6LL8mWukJVKRJg3wac4j6/I0Mrv Gzh/gFrnHz84C8wfcAxRQGEVg551rac= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-3-CYNybj1fMdeZNZqT5GEs0w-1; Sun, 29 Dec 2024 08:39:04 -0500 X-MC-Unique: CYNybj1fMdeZNZqT5GEs0w-1 X-Mimecast-MFC-AGG-ID: CYNybj1fMdeZNZqT5GEs0w Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-385d52591d6so4009139f8f.1 for ; Sun, 29 Dec 2024 05:39:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479543; x=1736084343; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ewOKMuYK43WJG2ALaY5n3pXvxddbNuZFCxaX4PT5PsA=; b=rVkXIrZTIqMYyytfYjVzKPoiVfezqZKkT7V4IRheGUtC5Jn6irDNvRZ5yZPUfXhVgu +WRlOBaedwExYbZ8jZB3B7ElHH4l2DHoxEqVkMLje3klBa8Ndiez4K3j/2q8VwfzWD1r vAe/9TYyxhapIzMt2yyc2pyW3QuBwZSS4CBLSF5cUHzwewBBzzCkrAFhWU1/w20RfmBc KTavMrPQvc9lq7p47PTxiNMjVBXCkThBS9/9iKSQfq3WCzOtKXK/9HJSORAY3pnz9NkW +5VDotXu4oEFwQukWvHiFTgIzNfrk/OBiByq038XcimdGx+ac/3+o6o0/ifBCrnDv+y7 9e0A== X-Gm-Message-State: AOJu0Yz8A5+cXKxiCTqFHVRNXk42eH2rhFXOGH0FxcuTGqbAWBoTQYU3 PBq43cdloPrNvE3ukVl79wlxQG6pD+Ad6+GQSuN+ZURCq20wCf27SzvaXohTF1CrWjwb0Q0Yn/A YakcwQzuAjupX7Yqy4MCZerhPlymdYJLJxqIgqzjVZXgMsvI86UyD4lWjVgT4CGa2S3DTq6vV/y OPcXUsVIlUkPiRoop8qBaEkVL9oj2ZO9jmnYx+YWl6 X-Gm-Gg: ASbGncsjIkbNDKcSaTF+0hGdf2NIBz3uRmIIkmQlr12GfDZrC2WbfvlvdmwUXkvoSyC GqVCTSirmqBlItrpAAEnqKU7I8cQGd4ae+7tyhV9mobU3DPv0BF+CjHg0xqUP/mh6ZN85y5yJAH Bpvznm3snCX06tPsf1sfDqPfc+b+iBBuv7vhGT8EvZk3adJOkfD+b2Jlc+eT2XOe/dss8njkd+k cqLCkBUSe03583WirJ/Enir+Fqi8bU0wdQjya1vgEmL/rCxm+u+pkCFS3qJhIRlYuWqO4EXCckv 7mNq8P2xSZzHc/8= X-Received: by 2002:a05:6000:1785:b0:385:e2b1:8fa with SMTP id ffacd0b85a97d-38a22a65256mr22353478f8f.30.1735479543057; Sun, 29 Dec 2024 05:39:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEm5DDYozxGhUMPYHO8RuhpKMMVMKCSWHaM9IC0inmAOFweYXzYwTqh+zNOy+uWW0YRkpIXww== X-Received: by 2002:a05:6000:1785:b0:385:e2b1:8fa with SMTP id ffacd0b85a97d-38a22a65256mr22353460f8f.30.1735479542722; Sun, 29 Dec 2024 05:39:02 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:39:01 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 09/14] xfs: add interface to set CRC on leaf attributes Date: Sun, 29 Dec 2024 14:38:31 +0100 Message-ID: <20241229133836.1194272-10-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 With attributes' data passed through page cache we need to update CRC when IO is complete. This function calculates CRC of newly written data and swaps CRC with a new one (the old one is still in there). Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_attr_leaf.c | 50 +++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.h | 1 + fs/xfs/xfs_trace.h | 1 + 3 files changed, 52 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index c657638efe04..409c91827b47 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -3035,3 +3035,53 @@ xfs_attr3_leaf_flipflags( return 0; } + +/* + * Set CRC field of remote attribute + */ +int +xfs_attr3_leaf_setcrc( + struct xfs_da_args *args) +{ + struct xfs_attr_leafblock *leaf; + struct xfs_attr_leaf_entry *entry; + struct xfs_attr_leaf_name_remote *name_rmt; + struct xfs_buf *bp; + struct xfs_mount *mp = args->dp->i_mount; + int error; + unsigned int whichcrc; + uint32_t crc; + + trace_xfs_attr_leaf_setcrc(args); + + xfs_calc_cksum(args->value, args->valuelen, &crc); + + /* + * Set up the operation. + */ + error = xfs_attr3_leaf_read(args->trans, args->dp, args->owner, + args->blkno, &bp); + if (error) + return error; + + leaf = bp->b_addr; + entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; + ASSERT((entry->flags & XFS_ATTR_INCOMPLETE) != 0); + + whichcrc = (entry->flags & XFS_ATTR_RMCRC_SEL) == 0; + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, + args->index); + name_rmt->crc[whichcrc] = crc; + xfs_trans_log_buf(args->trans, bp, + XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); + + /* Flip the XFS_ATTR_RMCRC_SEL bit to point to the right/new CRC and + * clear XFS_ATTR_INCOMPLETE bit as this is final point of directly + * mapped attr data write flow */ + entry->flags ^= XFS_ATTR_RMCRC_SEL; + entry->flags &= ~XFS_ATTR_INCOMPLETE; + xfs_trans_log_buf(args->trans, bp, + XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); + + return 0; +} diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h index 589f810eedc0..c8722c8accb0 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.h +++ b/fs/xfs/libxfs/xfs_attr_leaf.h @@ -66,6 +66,7 @@ int xfs_attr3_leaf_to_shortform(struct xfs_buf *bp, int xfs_attr3_leaf_clearflag(struct xfs_da_args *args); int xfs_attr3_leaf_setflag(struct xfs_da_args *args); int xfs_attr3_leaf_flipflags(struct xfs_da_args *args); +int xfs_attr3_leaf_setcrc(struct xfs_da_args *args); /* * Routines used for growing the Btree. diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 7b16cdd72e9d..5c3b8929179d 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -2189,6 +2189,7 @@ DEFINE_ATTR_EVENT(xfs_attr_leaf_to_node); DEFINE_ATTR_EVENT(xfs_attr_leaf_rebalance); DEFINE_ATTR_EVENT(xfs_attr_leaf_unbalance); DEFINE_ATTR_EVENT(xfs_attr_leaf_toosmall); +DEFINE_ATTR_EVENT(xfs_attr_leaf_setcrc); DEFINE_ATTR_EVENT(xfs_attr_node_addname); DEFINE_ATTR_EVENT(xfs_attr_node_get); From patchwork Sun Dec 29 13:38:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922691 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 479A41531C8 for ; Sun, 29 Dec 2024 13:39:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479549; cv=none; b=bWmhlA8UY2E63PGNC9JEQUUHFcPGiT1by8sa4KarQg69DKTr/ufe9njzEgSWv+rOjnjQExAbOLjxFOmF6JiwZ5KXkdtrzHaRozNC3cY2FeLPQAIkKOd6cuWB4Q1Gg6EtQN8vXaWF5l0TKSqkGXg/sVrR0yYmaYVUB69i5/oeRlY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479549; c=relaxed/simple; bh=ZhcZFHd5JVEpVLlW9VMPmicx5F+tcNphNkg/aZjNQRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sNbSQ3IqEOFMLjo5XdlQldv+SNHT9IgPycFOq3F5b4S2bB637SpDVjxMBx+NSxKGYU3eMRbfGsSHtyJ5XSd5VgsjxyE7JTH+4EmVVuZF6lmDI46MPlpAKbtv9p09nhv1WYsBDCw9rHvE/HRLeia0yPPyglM2cUv7l/7ieYc7ATA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LdYVTDgT; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LdYVTDgT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479547; h=from:from:reply-to:subject:subject: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=Nur/MaXbNbep0nGfnpuQnIYAkWa+dhGBZo7ukzuAicY=; b=LdYVTDgTKAYdiO2hmTyZhgC/dvcJVryKl0CHnq9vKgYzFZwksavdXv7EsXE/iQwpmrd6V5 PiIV/IGaqlgwjc3p69F844mLntWS20NqgShJ+wuzWzAzlhaelZ2OcsiJhh71IEuulL1pdW jcIbYg66bf96GKJpr1FtyJJwAu4J7IY= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-278-OgvfQQnbPpe4j-6uKxBuhw-1; Sun, 29 Dec 2024 08:39:06 -0500 X-MC-Unique: OgvfQQnbPpe4j-6uKxBuhw-1 X-Mimecast-MFC-AGG-ID: OgvfQQnbPpe4j-6uKxBuhw Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-38a2140a400so5204000f8f.0 for ; Sun, 29 Dec 2024 05:39:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479544; x=1736084344; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nur/MaXbNbep0nGfnpuQnIYAkWa+dhGBZo7ukzuAicY=; b=Xxk5q6VRG1JQbXo/RKyvYDfoQJBzTGqDjHycBMxp6JS/OG+gdyXxjVaBLwppN7UatX ENVGAtTTFuPVem9gN7YQ/t9NQG3+GQ3VBkSl6tuITeTfQWGKo2dkNFMIv7cECyZKjBXJ eV6bfZqjsj7zohtFDSyCrS2bt090f4DIpgGQyfBlUalnsocv+grIwIgxsQ5PEaS8zFUK QfbhEo1+fqwX52+Hrojdsb6tEftWOhk1Tl88bc0Vtgg2dmUMBIk3lDxzXybklWUS88uP 8hjdm/z4K322ggiedH1741Kbh60M93sSPmgIK+BO5rmjVSCymeb2TW57maXp82OVNjqU pOrg== X-Gm-Message-State: AOJu0Ywe6htLwqUjcx6l6AlNr01lpbg40OVn4b66Xr+FY6h98wpiv+Ve EE/LQv5ozhhX794uhD5FC4NmG+wE4chw1xYEeH7WOmyY9QvnDWLPT5HuXdehZBU3/5peGtJc2BK GC9NwebQuc4TfgE/QIEXAqhVvfn8+/3H98cEuigYOW39GP5NFJkx/6vo7iZ+m5nO5RCZhW/fpgx Pa0s7cRUoN57cgNDv5yiJpDlIkLlWQxkBC8wwnnkJd X-Gm-Gg: ASbGncsB+79Mw+iQ77sch2T2vrPKp/6k1C+ydCf8SQZ6gxnrWaV5xoh6PO12n2sHLWt xXxO7ysBYUtn25SxyyjUVUhiv4SB+RkEuSkYYNrqzKs5MD4chAisZdZQSKUy9FKtSVuMfEV/09k wJdZZjrg6hLtPe/lv/3cusqPkVP56bftL9ugcLLiUK188NyCIeSN3ESoQ9aO/59u5rpPUTPXqV5 7j7UQJkWdsB1JnjQyC6kwfmgGxa6hVCA8pZeeu9pQFMmSPUxrRLznKBu1milTgjLEd+0ulFqJX4 HJztX9asBFFmQ+A= X-Received: by 2002:a5d:5e09:0:b0:385:f72a:a3b0 with SMTP id ffacd0b85a97d-38a223fd417mr34649027f8f.55.1735479544330; Sun, 29 Dec 2024 05:39:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGt2JiTI+52hRdXTVo5j6kOA5o+ypnN61iCqRRoxRIF0zz5icEqvzhm8ZXrPqoWhScTWqZrKw== X-Received: by 2002:a5d:5e09:0:b0:385:f72a:a3b0 with SMTP id ffacd0b85a97d-38a223fd417mr34649013f8f.55.1735479543968; Sun, 29 Dec 2024 05:39:03 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:39:03 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 10/14] xfs: introduce XFS_ATTRUPDATE_FLAGS operation Date: Sun, 29 Dec 2024 14:38:32 +0100 Message-ID: <20241229133836.1194272-11-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The extended attributes mapped through page cache need a way to reset XFS_ATTR_INCOMPLETE flag and set data CRC when data IO is complete. Introduce this new operation which now applies only to leaf attributes. Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_attr.c | 19 ++++++++++++++++++- fs/xfs/libxfs/xfs_attr.h | 3 +++ fs/xfs/libxfs/xfs_log_format.h | 1 + fs/xfs/xfs_attr_item.c | 6 ++++++ fs/xfs/xfs_attr_item.h | 1 + fs/xfs/xfs_stats.h | 1 + 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 5060c266f776..55b18ec8bc10 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -855,6 +855,13 @@ xfs_attr_set_iter( attr->xattri_dela_state++; break; + case XFS_DAS_LEAF_FLAGS_UPDATE: + error = xfs_attr3_leaf_setcrc(args); + if (error) + return error; + attr->xattri_dela_state = XFS_DAS_DONE; + break; + case XFS_DAS_LEAF_SET_RMT: case XFS_DAS_NODE_SET_RMT: error = xfs_attr_rmtval_find_space(attr); @@ -1093,6 +1100,11 @@ xfs_attr_set( tres = M_RES(mp)->tr_attrrm; total = XFS_ATTRRM_SPACE_RES(mp); break; + case XFS_ATTRUPDATE_FLAGS: + XFS_STATS_INC(mp, xs_attr_flags); + tres = M_RES(mp)->tr_attrrm; + total = XFS_ATTRRM_SPACE_RES(mp); + break; } /* @@ -1119,6 +1131,11 @@ xfs_attr_set( break; } + if (op == XFS_ATTRUPDATE_FLAGS) { + xfs_attr_defer_add(args, XFS_ATTR_DEFER_FLAGS); + break; + } + /* Pure create fails if the attr already exists */ if (op == XFS_ATTRUPDATE_CREATE) goto out_trans_cancel; @@ -1126,7 +1143,7 @@ xfs_attr_set( break; case -ENOATTR: /* Can't remove what isn't there. */ - if (op == XFS_ATTRUPDATE_REMOVE) + if (op == XFS_ATTRUPDATE_REMOVE || op == XFS_ATTRUPDATE_FLAGS) goto out_trans_cancel; /* Pure replace fails if no existing attr to replace. */ diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 0e51d0723f9a..b851e2e4b63c 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -448,6 +448,7 @@ enum xfs_delattr_state { XFS_DAS_LEAF_ADD, /* Initial leaf add state */ XFS_DAS_LEAF_REMOVE, /* Initial leaf replace/remove state */ + XFS_DAS_LEAF_FLAGS_UPDATE, /* Update leaf XFS_ATTR_* flags and CRC */ XFS_DAS_NODE_ADD, /* Initial node add state */ XFS_DAS_NODE_REMOVE, /* Initial node replace/remove state */ @@ -477,6 +478,7 @@ enum xfs_delattr_state { { XFS_DAS_SF_REMOVE, "XFS_DAS_SF_REMOVE" }, \ { XFS_DAS_LEAF_ADD, "XFS_DAS_LEAF_ADD" }, \ { XFS_DAS_LEAF_REMOVE, "XFS_DAS_LEAF_REMOVE" }, \ + { XFS_DAS_LEAF_FLAGS_UPDATE, "XFS_DAS_LEAF_FLAGS_UPDATE" }, \ { XFS_DAS_NODE_ADD, "XFS_DAS_NODE_ADD" }, \ { XFS_DAS_NODE_REMOVE, "XFS_DAS_NODE_REMOVE" }, \ { XFS_DAS_LEAF_SET_RMT, "XFS_DAS_LEAF_SET_RMT" }, \ @@ -556,6 +558,7 @@ enum xfs_attr_update { XFS_ATTRUPDATE_UPSERT, /* set value, replace any existing attr */ XFS_ATTRUPDATE_CREATE, /* set value, fail if attr already exists */ XFS_ATTRUPDATE_REPLACE, /* set value, fail if attr does not exist */ + XFS_ATTRUPDATE_FLAGS, /* update attribute flags and metadata */ }; int xfs_attr_set(struct xfs_da_args *args, enum xfs_attr_update op, bool rsvd); diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index 15dec19b6c32..9f1b02a599d2 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -1035,6 +1035,7 @@ struct xfs_icreate_log { #define XFS_ATTRI_OP_FLAGS_PPTR_SET 4 /* Set parent pointer */ #define XFS_ATTRI_OP_FLAGS_PPTR_REMOVE 5 /* Remove parent pointer */ #define XFS_ATTRI_OP_FLAGS_PPTR_REPLACE 6 /* Replace parent pointer */ +#define XFS_ATTRI_OP_FLAGS_FLAGS_UPDATE 7 /* Update attribute flags */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index f683b7a9323f..f392c95905b5 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -908,6 +908,9 @@ xfs_attr_defer_add( else log_op = XFS_ATTRI_OP_FLAGS_REMOVE; break; + case XFS_ATTR_DEFER_FLAGS: + log_op = XFS_ATTRI_OP_FLAGS_FLAGS_UPDATE; + break; default: ASSERT(0); break; @@ -931,6 +934,9 @@ xfs_attr_defer_add( case XFS_ATTRI_OP_FLAGS_REMOVE: new->xattri_dela_state = xfs_attr_init_remove_state(args); break; + case XFS_ATTRI_OP_FLAGS_FLAGS_UPDATE: + new->xattri_dela_state = XFS_DAS_LEAF_FLAGS_UPDATE; + break; } xfs_defer_add(args->trans, &new->xattri_list, &xfs_attr_defer_type); diff --git a/fs/xfs/xfs_attr_item.h b/fs/xfs/xfs_attr_item.h index e74128cbb722..f6f169631eb7 100644 --- a/fs/xfs/xfs_attr_item.h +++ b/fs/xfs/xfs_attr_item.h @@ -57,6 +57,7 @@ enum xfs_attr_defer_op { XFS_ATTR_DEFER_SET, XFS_ATTR_DEFER_REMOVE, XFS_ATTR_DEFER_REPLACE, + XFS_ATTR_DEFER_FLAGS, }; void xfs_attr_defer_add(struct xfs_da_args *args, enum xfs_attr_defer_op op); diff --git a/fs/xfs/xfs_stats.h b/fs/xfs/xfs_stats.h index a61fb56ed2e6..007c22e2cad2 100644 --- a/fs/xfs/xfs_stats.h +++ b/fs/xfs/xfs_stats.h @@ -96,6 +96,7 @@ struct __xfsstats { uint32_t xs_attr_get; uint32_t xs_attr_set; uint32_t xs_attr_remove; + uint32_t xs_attr_flags; uint32_t xs_attr_list; uint32_t xs_iflush_count; uint32_t xs_icluster_flushcnt; From patchwork Sun Dec 29 13:38:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922693 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 17DF415820C for ; Sun, 29 Dec 2024 13:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479554; cv=none; b=RHfOo9PuwA701y9jOfz4PnCtfJhcm4SIuxweQO5mlhq9xE2GpR1gfLMZS4m5+ytHEQYiS7JYg6QWFr2tNMI9DMFsSFXvgznEQjhD5yqsCfjb84lyQNk/z/PjyX6tUyJ1mBy9dFGvAPdRkRLc0IZPE17Ty7aVfw9cH1Mu5+X+afY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479554; c=relaxed/simple; bh=0zWKacQlc9i9XxUkmK5NkdmAjIlpKZFQcR90rYZAxm8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K7TQd1KTS6U2ojTj8Xyso3cJXNokvieYZZvAZS0Bo4aPElsLP+PcTmPB2gqdyBzt+mA6Wt8sdkpucGMEigwhAlHWnWT++jatzpEMghp6NU/d93hOtZToVrNrycKww2/uVCnokzOL6oGig2LG+YsDpATJdGf2pAOYbusxft7ZwZs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DBLF4jP4; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DBLF4jP4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479551; h=from:from:reply-to:subject:subject: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=1Na2m5UMPWh3vwqiIBEvQcu/97KImYI+t91MlSg7cSc=; b=DBLF4jP48p1kZqNyHXUqYrkKdIdz4PSPFM2UP27voKdgrQIO+94E21aqJNyZA3wBiWuf3g 4jkEII5EWEsFH9a+LuMPVSGh00IMbaTixZ8mZbgZTd09dB9Ar50/iW13r8OQFHamY8Mjrj lth7f9PpRAcnaq9XRO0/YygCU24t4oo= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-398-iBfegatJNCiu-MABES_NNA-1; Sun, 29 Dec 2024 08:39:09 -0500 X-MC-Unique: iBfegatJNCiu-MABES_NNA-1 X-Mimecast-MFC-AGG-ID: iBfegatJNCiu-MABES_NNA Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-385d52591d6so4009162f8f.1 for ; Sun, 29 Dec 2024 05:39:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479548; x=1736084348; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Na2m5UMPWh3vwqiIBEvQcu/97KImYI+t91MlSg7cSc=; b=aeQJ4Y4Gf277w7V/e1sXuQFJ9PMA6i11gVOv0DxWNu7KWIsWTqD5YuP8Z5WMfTQFNu ngFICVcF3AKHqKC/iZdoQVBCAJ/7b03KaTgvwiHaSY6YAr1JuyaWXpPDYk60UOdbieIf XbpJm8LuRrlVIeHh1xDCZml/hKFeaWSVACORGNjX+z5eACD6RfFIp/gjwwy/oSdphdqv zi4yUNFpccPsfVjHybJlS1qvWJkRCOlwWyFJfYEWlc6kHm18KozVgAAOJVavrFF0A9Ox nvEu7El5nnz5uytOyeiUfkZrKTNY5e88xwLugKADAutr7RQYD1L1KXnRciysz2WA+zkk o/xw== X-Gm-Message-State: AOJu0YzF4A1rCYVo0oZE9YjkG//G26nOQy/6UMccY8key53g6AuYZwvc OFxwCD2ucWv/43rhjdFYztLISm0rxe5Wh55rlo67ODN/qBXmEwR1Q5YNJK5Gq4HB+9s68Fkqru8 tS04VnxsII2cnZLHUacVsKEZU//NgOig4HfA6HVQKyVn1rDdVnTU6MgRLHXXONMz5VNFJEZQAWM /rqWS2ogAnCJDelw8pcjI6CNBsRgEu0DCjoN8PSBhI X-Gm-Gg: ASbGnctochbxfXvckFC2L1psgL/8HDer9S5DcEt+2CrqPT2WdV65UYKzt5op7A3zOMi wy2uZ9RCQcPc03tF8L68uDsA1M7QZnKb8FPZFqDM8mfj4mstkmWiuu77sqfDFnadVjAaYDORrlq mr1gM6QTComVgo5nWP+SUNQTyc87fGiaNpJMhN4sn21zOMi853RxwVqrD8RkaoQl8hXCUbdeRjQ njnDadm8ROVCkgOezj3Z6OfaI/YrJYIOvt94Niu9J5wP9Nt7Zf1U39hwpjagMDDmi5/VZSQUiH6 zwAwWekXk5c7odw= X-Received: by 2002:a05:6000:18a5:b0:386:3672:73e4 with SMTP id ffacd0b85a97d-38a1a2746a3mr31667310f8f.26.1735479546415; Sun, 29 Dec 2024 05:39:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHFM47AA0b3ZWvyliS/St2aNASRxqmSACTqLZRz0sidCnI0meOHabfaEgNjGexLisPtRzYWQ== X-Received: by 2002:a05:6000:18a5:b0:386:3672:73e4 with SMTP id ffacd0b85a97d-38a1a2746a3mr31667289f8f.26.1735479545976; Sun, 29 Dec 2024 05:39:05 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:39:04 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn , Andrey Albershteyn Subject: [PATCH 11/14] xfs: add interface for page cache mapped remote xattrs Date: Sun, 29 Dec 2024 14:38:33 +0100 Message-ID: <20241229133836.1194272-12-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andrey Albershteyn Leafs of the remote attributes contain xfs_attr3_rmt_hdr with CRC of the extended attribute and owner info. Each block of the extent has this header. Due to this fact we can not easily map the content of extended attribute to the page. This would be very helpful for fsverity as we can use extended attributes to store merkle tree and map these blocks to the page cache. This commit changes format of the leafs by shifting CRC the btree name struct. This however creates inconsistency problem as CRC update could not happen even though data is updated. This is solved by storing both CRCs - for old data and for the new one. Attribute flag points to the correct CRC. Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_attr.c | 189 +++++++++++++++++++++++++++++++- fs/xfs/libxfs/xfs_attr.h | 8 ++ fs/xfs/libxfs/xfs_attr_remote.c | 12 -- fs/xfs/libxfs/xfs_da_btree.h | 1 + fs/xfs/libxfs/xfs_da_format.h | 3 + fs/xfs/libxfs/xfs_ondisk.h | 9 +- fs/xfs/libxfs/xfs_sb.c | 2 + fs/xfs/xfs_mount.h | 2 + 8 files changed, 207 insertions(+), 19 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 55b18ec8bc10..d357405f22ee 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -27,6 +27,7 @@ #include "xfs_attr_item.h" #include "xfs_xattr.h" #include "xfs_parent.h" +#include "xfs_iomap.h" struct kmem_cache *xfs_attr_intent_cache; @@ -344,6 +345,175 @@ xfs_attr_set_resv( return ret; } +/* + * Find attribute specified in args and return iomap pointing to the attribute + * data + */ +int +xfs_attr_read_iomap( + struct xfs_da_args *args, + struct iomap *iomap) +{ + struct xfs_inode *ip = args->dp; + struct xfs_mount *mp = ip->i_mount; + int error; + struct xfs_bmbt_irec map[1]; + int nmap = 1; + int seq; + unsigned int lockmode = XFS_ILOCK_SHARED; + int ret; + uint64_t pos = xfs_attr_get_position(args); + + ASSERT(!args->region_offset); + + if (xfs_is_shutdown(mp)) + return -EIO; + + /* We just need to find the attribute and block it's pointing + * to. The reading of data would be done by iomap */ + args->valuelen = 0; + error = xfs_attr_get(args); + if (error) + return error; + + if (xfs_need_iread_extents(&ip->i_af)) + lockmode = XFS_ILOCK_EXCL; + xfs_ilock(ip, lockmode); + error = xfs_bmapi_read(ip, (xfs_fileoff_t)args->rmtblkno, + args->rmtblkcnt, map, &nmap, + XFS_BMAPI_ATTRFORK); + xfs_iunlock(ip, lockmode); + if (error) + return error; + + map[0].br_startoff = XFS_B_TO_FSB(mp, pos | args->region_offset); + + seq = xfs_iomap_inode_sequence(ip, IOMAP_F_XATTR); + trace_xfs_iomap_found(ip, pos, args->valuelen, XFS_ATTR_FORK, map); + ret = xfs_bmbt_to_iomap(ip, iomap, map, 0, IOMAP_F_XATTR, seq); + /* Attributes are at args->region_offset in cache, beyond EOF of the + * file */ + iomap->flags |= IOMAP_F_BEYOND_EOF; + + return ret; +} + +int +xfs_attr_read_end_io( + struct xfs_da_args *args) +{ + struct xfs_inode *ip = args->dp; + struct xfs_attr_leafblock *leaf; + struct xfs_attr_leaf_entry *entry; + struct xfs_attr_leaf_name_remote *name_rmt; + struct xfs_buf *bp; + struct xfs_mount *mp = args->dp->i_mount; + uint32_t crc; + int error; + unsigned int whichcrc; + + xfs_ilock(ip, XFS_ILOCK_SHARED); + + if (!xfs_inode_hasattr(args->dp)) { + error = -ENOATTR; + goto out_unlock; + } + + error = xfs_iread_extents(args->trans, args->dp, XFS_ATTR_FORK); + if (error) + goto out_unlock; + + error = xfs_attr3_leaf_read(args->trans, args->dp, args->owner, + args->blkno, &bp); + if (error) + goto out_unlock; + + leaf = bp->b_addr; + entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; + + whichcrc = (entry->flags & XFS_ATTR_RMCRC_SEL) != 0; + name_rmt = xfs_attr3_leaf_name_remote(&(mp->m_sb), leaf, + args->index); + + xfs_calc_cksum(args->value, args->valuelen, &crc); + error = name_rmt->crc[whichcrc] != crc; + if (error) { + if (name_rmt->crc[~whichcrc & 1] != crc) { + error = -EFSCORRUPTED; + goto out_buf_relse; + } else { + error = -EFSBADCRC; + goto out_buf_relse; + } + } + +out_buf_relse: + xfs_buf_relse(bp); +out_unlock: + xfs_iunlock(args->dp, XFS_ILOCK_SHARED); + return error; +} + +/* + * Create an attribute described in args and return iomap pointing to the extent + * where attribute data has to be written. + * + * Created attribute has XFS_ATTR_INCOMPLETE set, and doesn't have any data CRC. + * Therefore, when IO is complete xfs_attr_write_end_ioend() need to be called. + */ +int +xfs_attr_write_iomap( + struct xfs_da_args *args, + struct iomap *iomap) +{ + struct xfs_inode *ip = args->dp; + struct xfs_mount *mp = ip->i_mount; + int error; + int nmap = 1; + int seq; + struct xfs_bmbt_irec imap[1]; + uint64_t pos = xfs_attr_get_position(args); + unsigned int blksize = mp->m_attr_geo->blksize; + + ASSERT(!args->region_offset); + + if (xfs_is_shutdown(mp)) + return -EIO; + + /* We just want to allocate blocks without copying any data there */ + args->op_flags |= XFS_DA_OP_EMPTY; + args->valuelen = round_up(min_t(int, args->valuelen, blksize), blksize); + + error = xfs_attr_set(args, XFS_ATTRUPDATE_UPSERT, false); + if (error) + return error; + + ASSERT(args->dp->i_af.if_format != XFS_DINODE_FMT_LOCAL); + xfs_ilock(ip, XFS_ILOCK_SHARED); + error = xfs_bmapi_read(ip, (xfs_fileoff_t)args->rmtblkno, + args->rmtblkcnt, imap, &nmap, + XFS_BMAPI_ATTRFORK); + xfs_iunlock(ip, XFS_ILOCK_SHARED); + if (error) + return error; + + /* Instead of xattr extent offset, which will be over data, we need + * merkle tree offset in page cache */ + imap[0].br_startoff = XFS_B_TO_FSBT(mp, pos | args->region_offset); + + seq = xfs_iomap_inode_sequence(ip, IOMAP_F_XATTR); + xfs_bmbt_to_iomap(ip, iomap, imap, 0, IOMAP_F_XATTR, seq); + + return 0; +} + +int +xfs_attr_write_end_ioend( + struct xfs_da_args *args) +{ + return xfs_attr_set(args, XFS_ATTRUPDATE_FLAGS, false); +} + /* * Add an attr to a shortform fork. If there is no space, * xfs_attr_shortform_addname() will convert to leaf format and return -ENOSPC. @@ -642,11 +812,15 @@ xfs_attr_rmtval_alloc( goto out; } - if (!(args->op_flags & XFS_DA_OP_EMPTY)) { + if (args->op_flags & XFS_DA_OP_EMPTY) { + /* Set XFS_ATTR_INCOMLETE flag as attribute doesn't have a value + * yet (which should be written by iomap). */ + error = xfs_attr3_leaf_setflag(args); + } else { error = xfs_attr_rmtval_set_value(args); - if (error) - return error; } + if (error) + return error; attr->xattri_dela_state = xfs_attr_complete_op(attr, ++attr->xattri_dela_state); @@ -1613,3 +1787,12 @@ xfs_attr_intent_destroy_cache(void) kmem_cache_destroy(xfs_attr_intent_cache); xfs_attr_intent_cache = NULL; } + +/* Retrieve attribute position from the attr data */ +uint64_t +xfs_attr_get_position( + struct xfs_da_args *args) +{ + ASSERT(args->namelen == sizeof(uint64_t)); + return be64_to_cpu(*(uint64_t*)args->name); +} diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index b851e2e4b63c..3d137117154e 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -6,6 +6,8 @@ #ifndef __XFS_ATTR_H__ #define __XFS_ATTR_H__ +#include + struct xfs_inode; struct xfs_da_args; struct xfs_attr_list_context; @@ -569,6 +571,10 @@ bool xfs_attr_namecheck(unsigned int attr_flags, const void *name, size_t length); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); struct xfs_trans_res xfs_attr_set_resv(const struct xfs_da_args *args); +int xfs_attr_read_iomap(struct xfs_da_args *args, struct iomap *iomap); +int xfs_attr_read_end_io(struct xfs_da_args *args); +int xfs_attr_write_iomap(struct xfs_da_args *args, struct iomap *iomap); +int xfs_attr_write_end_ioend(struct xfs_da_args *args); /* * Check to see if the attr should be upgraded from non-existent or shortform to @@ -652,4 +658,6 @@ void xfs_attr_intent_destroy_cache(void); int xfs_attr_sf_totsize(struct xfs_inode *dp); int xfs_attr_add_fork(struct xfs_inode *ip, int size, int rsvd); +uint64_t xfs_attr_get_position(struct xfs_da_args *args); + #endif /* __XFS_ATTR_H__ */ diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 4c44ce1c8a64..17125e2e6c51 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -62,13 +62,6 @@ xfs_attr3_rmt_blocks( struct xfs_mount *mp, unsigned int attrlen) { - /* - * Each contiguous block has a header, so it is not just a simple - * attribute length to FSB conversion. - */ - if (xfs_has_crc(mp)) - return howmany(attrlen, xfs_attr3_rmt_buf_space(mp)); - return XFS_B_TO_FSB(mp, attrlen); } @@ -467,11 +460,6 @@ xfs_attr_rmt_find_hole( unsigned int blkcnt; xfs_fileoff_t lfileoff = 0; - /* - * Because CRC enable attributes have headers, we can't just do a - * straight byte to FSB conversion and have to take the header space - * into account. - */ blkcnt = xfs_attr3_rmt_blocks(mp, args->rmtvaluelen); error = xfs_bmap_first_unused(args->trans, args->dp, blkcnt, &lfileoff, XFS_ATTR_FORK); diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index 2428a3a466cb..81e3426ccb77 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -85,6 +85,7 @@ typedef struct xfs_da_args { int rmtblkcnt2; /* remote attr value block count */ int rmtvaluelen2; /* remote attr value length in bytes */ enum xfs_dacmp cmpresult; /* name compare result for lookups */ + loff_t region_offset; /* offset of the iomapped attr region */ } xfs_da_args_t; /* diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index afc25b6d805e..bf0f73624446 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -645,6 +645,7 @@ typedef struct xfs_attr_leaf_name_local { } xfs_attr_leaf_name_local_t; typedef struct xfs_attr_leaf_name_remote { + __be32 crc[2]; /* CRC of the xattr data */ __be32 valueblk; /* block number of value bytes */ __be32 valuelen; /* number of bytes in value */ __u8 namelen; /* length of name bytes */ @@ -715,11 +716,13 @@ struct xfs_attr3_leafblock { #define XFS_ATTR_ROOT_BIT 1 /* limit access to trusted attrs */ #define XFS_ATTR_SECURE_BIT 2 /* limit access to secure attrs */ #define XFS_ATTR_PARENT_BIT 3 /* parent pointer attrs */ +#define XFS_ATTR_RMCRC_SEL_BIT 4 /* which CRC field is primary */ #define XFS_ATTR_INCOMPLETE_BIT 7 /* attr in middle of create/delete */ #define XFS_ATTR_LOCAL (1u << XFS_ATTR_LOCAL_BIT) #define XFS_ATTR_ROOT (1u << XFS_ATTR_ROOT_BIT) #define XFS_ATTR_SECURE (1u << XFS_ATTR_SECURE_BIT) #define XFS_ATTR_PARENT (1u << XFS_ATTR_PARENT_BIT) +#define XFS_ATTR_RMCRC_SEL (1u << XFS_ATTR_RMCRC_SEL_BIT) #define XFS_ATTR_INCOMPLETE (1u << XFS_ATTR_INCOMPLETE_BIT) #define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | \ diff --git a/fs/xfs/libxfs/xfs_ondisk.h b/fs/xfs/libxfs/xfs_ondisk.h index ad0dedf00f18..2617081bf989 100644 --- a/fs/xfs/libxfs/xfs_ondisk.h +++ b/fs/xfs/libxfs/xfs_ondisk.h @@ -96,10 +96,11 @@ xfs_check_ondisk_structs(void) XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_local, valuelen, 0); XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_local, namelen, 2); XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_local, nameval, 3); - XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, valueblk, 0); - XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, valuelen, 4); - XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, namelen, 8); - XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, name, 9); + XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, crc, 0); + XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, valueblk, 8); + XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, valuelen, 12); + XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, namelen, 16); + XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, name, 17); XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leafblock, 32); XFS_CHECK_STRUCT_SIZE(struct xfs_attr_sf_hdr, 4); XFS_CHECK_OFFSET(struct xfs_attr_sf_hdr, totsize, 0); diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 3b5623611eba..20395ba66b94 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -183,6 +183,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_PARENT; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) features |= XFS_FEAT_METADIR; + if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_DXATTR) + features |= XFS_FEAT_DXATTR; return features; } diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index d772d908ba3c..1fa4a57421c3 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -330,6 +330,7 @@ typedef struct xfs_mount { #define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */ #define XFS_FEAT_EXCHANGE_RANGE (1ULL << 27) /* exchange range */ #define XFS_FEAT_METADIR (1ULL << 28) /* metadata directory tree */ +#define XFS_FEAT_DXATTR (1ULL << 29) /* directly mapped xattrs */ /* Mount features */ #define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ @@ -386,6 +387,7 @@ __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) __XFS_HAS_FEAT(large_extent_counts, NREXT64) __XFS_HAS_FEAT(exchange_range, EXCHANGE_RANGE) __XFS_HAS_FEAT(metadir, METADIR) +__XFS_HAS_FEAT(dxattr, DXATTR) static inline bool xfs_has_rtgroups(struct xfs_mount *mp) { From patchwork Sun Dec 29 13:38:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922692 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 8EFF91531C8 for ; Sun, 29 Dec 2024 13:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479553; cv=none; b=H6grgp0CFtsvi7EKQYMxyD4LsFkr8PYhnV7lKKy4ng+HcxM9lceR+qpgTaTUDQ2kxBNoAof8R29Z1U6sMxtWY/SEE75GmmKfRJjtxNDPwDL+EORZ8guaHkJdJybS/3/QGSg/RW3DL8OgEHIo/pNqog8VjJuG8MQED5zZyCS7Cgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479553; c=relaxed/simple; bh=3zha2mVjvSiLONh9VkK94JPvtZiYkkS57TdNFCuYMSY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L8yO0lGetoWKc3nBJf5TbNHnZ/GPB7qk6ZF0jaFngG+SGAjRCfK5V9NeZotCKDS0FjqiZwDb5toZ6YaxNJhcQ8YIWWNntdi0Lhhy0JD9ul0Q9elMBYszFS01RyyRhEyqwuQSOPPY/Dax8XfVLeMxujDA9LGviiO/3qvYFvOzaXE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Fz/+a0DK; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Fz/+a0DK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479550; h=from:from:reply-to:subject:subject: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=5b8P8+8ryCRE/uHgy93N1n9HZ5fMNhiJhoyUXPFs1ls=; b=Fz/+a0DKnmxP/4P3KhFbTSXLozo+vI+WfGhNj+3obvv+HBhfiHw8oeEdaY1K8sssTTrjX+ m/zUjipRkJFaOEAQmRC0oR9a5wC1hB97kCHh2N+cKzmxbXlNY0N4l5HYKPj4swZdbL+iUn UAfR29Qo2ixAPjAgZZ24Wrtn+CTD0gU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-391-lfaeC-BgOI2Ly0Fp3RlnAg-1; Sun, 29 Dec 2024 08:39:09 -0500 X-MC-Unique: lfaeC-BgOI2Ly0Fp3RlnAg-1 X-Mimecast-MFC-AGG-ID: lfaeC-BgOI2Ly0Fp3RlnAg Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3862e986d17so3770799f8f.3 for ; Sun, 29 Dec 2024 05:39:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479547; x=1736084347; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5b8P8+8ryCRE/uHgy93N1n9HZ5fMNhiJhoyUXPFs1ls=; b=X5ApYSmj4aBImYmssjumqQuV/qh2an1Rqg22waADGeyBm3wRvwBbFm2M1/mGL6Pj+K QyQSxcFzBatSqT73G9UWgyhm09UEJ299QrlAHE9+oRbGP5qMQ3FWz84caPfL94UPd9Mh u7h7VAcS7ZS84EpnLEY01irJRh3d+WRBNZtIV67zN73mwpzfq/BsbCd9/wqkWY+y6gKu D1ZikxG6zS4DtQRqJq8DrhED4R6UOGgJ5aizj5I8FtsKyqwIo137f2MjVMYBI4x49CWG ov+jEGFBunI2/aOFpQ3BwDPos8EQmf80bbD5F4LX9m1+VRCyXjUy0EKviFORiEq7phvi SJvA== X-Gm-Message-State: AOJu0Ywvp/3CKyWwgVv9gs8V2WPpNlpihc4XEJcMbK9FEvtDdhcol5MW igAB5SJZIGufzNGEfau9T/Id/yAy8bKIfb483yujnrKMvvmKmTwgXr6s30r/Rpi92tmoXHFDwqP j4iSkZBLy+WSBxSB3Sdg3ZqGtEgDrHTX0cSZKvaVkrVN5Q5bSLiIsRp4xFfL0yGnSPXFl0+NjfN e1v5MS5MAEhx1LjxOCaDZHJj7SBI2nL5uhfwIvL3sr X-Gm-Gg: ASbGncvW8tctewKxprf3k+NjFGnJK5/Xb0PoBqSJ4YYk9sXZxxK10C1oGMOKHeoEYsu PJGBa+j5qWQHvVpv1b+GZ/AkFKok79oCt7yMPThlJ339S2GZY/XPj8fP/C1IxC9vGc91GNtOoDS p4mSN666uiOIc7dOPgYBXQdWweGR6LgLG/P2spdvHXKgxtG/YQqpDt1goRa7cArWMe0xnrtlf5l lg0AYILTIcc27NmPeJ/INfXTm+nLkVlUHatstoYMEOqs4ZvYZ8/ZRV85Su32XR4anAIm062Ky8Q wxpawlBahh4jUmc= X-Received: by 2002:adf:9786:0:b0:38a:418e:bee with SMTP id ffacd0b85a97d-38a418e0e33mr9145568f8f.42.1735479547518; Sun, 29 Dec 2024 05:39:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXwrMBQvqmuujgBztiDukwzUFgvJPLJm4B5g363CKvis8dYYG6Wyt1ZxEqRLP2ZLVI/xcFGQ== X-Received: by 2002:adf:9786:0:b0:38a:418e:bee with SMTP id ffacd0b85a97d-38a418e0e33mr9145556f8f.42.1735479547124; Sun, 29 Dec 2024 05:39:07 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:39:06 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 12/14] xfs: parse both remote attr name on-disk formats Date: Sun, 29 Dec 2024 14:38:34 +0100 Message-ID: <20241229133836.1194272-13-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The new format has ->crc[2] field. This field is overlapped with anything what is before this remote attr name, for filesystems without dxattr. Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_da_format.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index bf0f73624446..4034530ad023 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -781,7 +781,13 @@ xfs_attr3_leaf_name_remote( xfs_attr_leafblock_t *leafp, int idx) { - return (xfs_attr_leaf_name_remote_t *)xfs_attr3_leaf_name(leafp, idx); + char *leaf = xfs_attr3_leaf_name(leafp, idx); + /* Overlap xfs_attr_leaf_name_remote_t with anything which is before. + * The overlap is created by ->crc[2] and is not used for filesystem + * without DXATTR. */ + if (!xfs_sb_has_incompat_feature(sb, XFS_SB_FEAT_INCOMPAT_DXATTR)) + return (xfs_attr_leaf_name_remote_t *)(leaf - 2*sizeof(__be32)); + return (xfs_attr_leaf_name_remote_t *)leaf; } static inline xfs_attr_leaf_name_local_t * From patchwork Sun Dec 29 13:38:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922694 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 65DD315CD74 for ; Sun, 29 Dec 2024 13:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479555; cv=none; b=tlvo0UQVM6rVMGZl5iH9533pFw5PlhdNw2cRtCkHiuZmZ808JkQDG4G+QeNQeiZExM6zu0kr6sXe+A1EefrC2coCF0aHq1kuoVdup0VqOecYv0U3ToIFbMlDBcHBdBize4WfzztlZDs+LRfrAEUPEun1oGiFZG2qlwHK/0XkOdE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479555; c=relaxed/simple; bh=Q2WwOg9+DJLtNjg+TkowiEs/XtD9AbIQjmY7592fRHM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i+AMd0VyrceIJ04ud4smfTJ/uIC6SRLzHzzKyAajg4O+Wd8GeyjJF4XK+MuviW4KaRNyEiw+X4TmtBY7Zeo3CQKHt2cB0HnAKaQ2GH3MgGdHfmAtQfmryLj41EX3cSdcC5rFHV4pwJ61ZPi7U/ORAnrCCQu4iq+zZg3wnFkWU+8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SrZ0XsXv; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SrZ0XsXv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479552; h=from:from:reply-to:subject:subject: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=7CFSQTd34Wiy7tERJmFVlaLJFpO5L40TLXgtta4Tg/w=; b=SrZ0XsXvnXZO60Q3DnM1Ty8Te6/xjB2JYfEj6/gKLz/DKnMovsgXuUE4DDMycCSAor1rX1 OMcv7DhV1u6o4UE6qtUvGb+bHUeFsowcQJcAehrZBbHkMpwBCDoWc1s+7/qRaWgLyT+mbD Afuc+c4sHOGm9y/EN199VbTSueM1t1Y= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-Oem9gmsQP7-4uZHSyRnJ5A-1; Sun, 29 Dec 2024 08:39:11 -0500 X-MC-Unique: Oem9gmsQP7-4uZHSyRnJ5A-1 X-Mimecast-MFC-AGG-ID: Oem9gmsQP7-4uZHSyRnJ5A Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4361a8fc3bdso46048155e9.2 for ; Sun, 29 Dec 2024 05:39:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479549; x=1736084349; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7CFSQTd34Wiy7tERJmFVlaLJFpO5L40TLXgtta4Tg/w=; b=pVPVwnZixRzDZrqz8M1Txd0uwdwU4UwQdjeeCfAzR/bFd5NpoMeU3X3zC6MmDeBsdn ZUdZAlfJQugoyaSC1p7gcyBQdcLb7xslAp49LW7oBqFekk+CF0E7dKAiChCLRf15+k2u 3RMQxDrFZpnD+TFN4oNkOYVn6PlGHr92m2QEHJSnKQ++T/FaM21U66nzd0G/+DX/RGKK ow755g9xsoaD8VAHcv5DH6+6q0jQk7ci4M/Ev/wxesSuSUOL6QEyhH2aEmcGt+U7whro n0e8ftgm31wVwRUwPKjGFi09kB1nnC9NuXo7WicznoxXh/3lRWbylP40apzW68BnUkq8 r8lw== X-Gm-Message-State: AOJu0YznVnw5fd/Y9Q3dNhofTuzPVp4u+/TJ2fhV2jGOh2uDWezGPJVM YwGUmbZ4OouaX7Fd85gUSoC4eaTf9kRsDGI3RNrpNi9NtJGdz99cZo3NFa5Q+um+bSZlMf3W37I D5HIMAujUXXJCSoTOy6nfon0qM82bW8KK9lDuYn8JprIEJZyHkQOc2E5SN+hPECV8pxL45gU+if VNgb69RsYxDrqiEISpfMInwyBZ8CGnIqFyMNWBvNHB X-Gm-Gg: ASbGnctQEhr3t8deyk6BbYJJHHRwZ6IShvavIYkOIIww7rIOWZC3hyWH5auE0fO2KXd F3VsCRP9PEVCseA99N6TRxtx56z9qkejqBirPu6zKdkkdzDTe+TgOMj3v9TZ6qo843xIkSX5EN6 6KkPMehb8cW1q1i0U2t2q9nojMYfMTlYy4jVOtfZGsUGCzDeSmUTsJ+ZdcftUzH6xgk63lTpgAC ujNJx5LcZhc72bAwbw8kr63POdwpFLW+f3BpBr/EWufpy7GGka/qhPOI+3PxFLg6CBtGxGBF/Lp 1xCb7c+hKjRP19s= X-Received: by 2002:a05:600c:4f09:b0:434:a711:ace4 with SMTP id 5b1f17b1804b1-4366864636dmr292044755e9.17.1735479549461; Sun, 29 Dec 2024 05:39:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDyXbTgo4zFyG4Patn2rJGpCuCowlFQQ365rQGhKTGSsk50nZmGwx6JfIgv39SqZCgrscBZg== X-Received: by 2002:a05:600c:4f09:b0:434:a711:ace4 with SMTP id 5b1f17b1804b1-4366864636dmr292044595e9.17.1735479548976; Sun, 29 Dec 2024 05:39:08 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.39.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:39:07 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 13/14] xfs: do not use xfs_attr3_rmt_hdr for remote value blocks for dxattr Date: Sun, 29 Dec 2024 14:38:35 +0100 Message-ID: <20241229133836.1194272-14-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Darrick J. Wong" Don't try to use xfs_attr3_rmt_hdr for directly mapped attribute's data blocks as it's not there. These blocks don't have header. The CRC is located in the btree structure and are verified on io-completion. Signed-off-by: Darrick J. Wong Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_attr.c | 6 ++- fs/xfs/libxfs/xfs_attr_leaf.c | 5 +- fs/xfs/libxfs/xfs_attr_remote.c | 91 ++++++++++++++++++++++++++++----- fs/xfs/libxfs/xfs_attr_remote.h | 8 ++- fs/xfs/libxfs/xfs_da_format.h | 2 +- fs/xfs/libxfs/xfs_shared.h | 1 + fs/xfs/xfs_attr_inactive.c | 2 +- 7 files changed, 94 insertions(+), 21 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index d357405f22ee..e452ca55241f 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -321,7 +321,8 @@ xfs_attr_calc_size( * Out of line attribute, cannot double split, but * make room for the attribute value itself. */ - uint dblocks = xfs_attr3_rmt_blocks(mp, args->valuelen); + uint dblocks = xfs_attr3_rmt_blocks(mp, args->attr_filter, + args->valuelen); nblks += dblocks; nblks += XFS_NEXTENTADD_SPACE_RES(mp, dblocks, XFS_ATTR_FORK); } @@ -1263,7 +1264,8 @@ xfs_attr_set( } if (!local) - rmt_blks = xfs_attr3_rmt_blocks(mp, args->valuelen); + rmt_blks = xfs_attr3_rmt_blocks(mp, args->attr_filter, + args->valuelen); tres = xfs_attr_set_resv(args); total = args->total; diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 409c91827b47..7e3577a8e5de 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -1573,7 +1573,8 @@ xfs_attr3_leaf_add_work( name_rmt->valuelen = 0; name_rmt->valueblk = 0; args->rmtblkno = 1; - args->rmtblkcnt = xfs_attr3_rmt_blocks(mp, args->valuelen); + args->rmtblkcnt = xfs_attr3_rmt_blocks(mp, args->attr_filter, + args->valuelen); args->rmtvaluelen = args->valuelen; } xfs_trans_log_buf( @@ -2512,6 +2513,7 @@ xfs_attr3_leaf_lookup_int( args->rmtblkno = be32_to_cpu(name_rmt->valueblk); args->rmtblkcnt = xfs_attr3_rmt_blocks( args->dp->i_mount, + args->attr_filter, args->rmtvaluelen); return -EEXIST; } @@ -2561,6 +2563,7 @@ xfs_attr3_leaf_getvalue( args->rmtvaluelen = be32_to_cpu(name_rmt->valuelen); args->rmtblkno = be32_to_cpu(name_rmt->valueblk); args->rmtblkcnt = xfs_attr3_rmt_blocks(args->dp->i_mount, + args->attr_filter, args->rmtvaluelen); return xfs_attr_copy_value(args, NULL, args->rmtvaluelen); } diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 17125e2e6c51..e90a62c61f28 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -43,14 +43,23 @@ * the logging system and therefore never have a log item. */ +static inline bool +xfs_attr3_rmt_has_header( + struct xfs_mount *mp, + unsigned int attrns) +{ + return xfs_has_crc(mp) && !xfs_has_dxattr(mp); +} + /* How many bytes can be stored in a remote value buffer? */ inline unsigned int xfs_attr3_rmt_buf_space( - struct xfs_mount *mp) + struct xfs_mount *mp, + unsigned int attrns) { unsigned int blocksize = mp->m_attr_geo->blksize; - if (xfs_has_crc(mp)) + if (xfs_attr3_rmt_has_header(mp, attrns)) return blocksize - sizeof(struct xfs_attr3_rmt_hdr); return blocksize; @@ -60,8 +69,16 @@ xfs_attr3_rmt_buf_space( unsigned int xfs_attr3_rmt_blocks( struct xfs_mount *mp, + unsigned int attrns, unsigned int attrlen) { + /* + * Each contiguous block has a header, so it is not just a simple + * attribute length to FSB conversion. + */ + if (xfs_attr3_rmt_has_header(mp, attrns)) + return howmany(attrlen, xfs_attr3_rmt_buf_space(mp, attrns)); + return XFS_B_TO_FSB(mp, attrlen); } @@ -241,6 +258,42 @@ const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = { .verify_struct = xfs_attr3_rmt_verify_struct, }; +static void +xfs_attr3_rmtdxattr_read_verify( + struct xfs_buf *bp) +{ +} + +static xfs_failaddr_t +xfs_attr3_rmtdxattr_verify_struct( + struct xfs_buf *bp) +{ + return NULL; +} + +static void +xfs_attr3_rmtdxattr_write_verify( + struct xfs_buf *bp) +{ +} + +const struct xfs_buf_ops xfs_attr3_rmtdxattr_buf_ops = { + .name = "xfs_attr3_remote_dxattr", + .magic = { 0, 0 }, + .verify_read = xfs_attr3_rmtdxattr_read_verify, + .verify_write = xfs_attr3_rmtdxattr_write_verify, + .verify_struct = xfs_attr3_rmtdxattr_verify_struct, +}; + +inline const struct xfs_buf_ops * +xfs_attr3_remote_buf_ops( + struct xfs_mount *mp) +{ + if (xfs_has_dxattr(mp)) + return &xfs_attr3_rmtdxattr_buf_ops; + return &xfs_attr3_rmt_buf_ops; +} + STATIC int xfs_attr3_rmt_hdr_set( struct xfs_mount *mp, @@ -286,6 +339,7 @@ xfs_attr_rmtval_copyout( struct xfs_buf *bp, struct xfs_inode *dp, xfs_ino_t owner, + unsigned int attrns, unsigned int *offset, unsigned int *valuelen, uint8_t **dst) @@ -299,11 +353,11 @@ xfs_attr_rmtval_copyout( while (len > 0 && *valuelen > 0) { unsigned int hdr_size = 0; - unsigned int byte_cnt = xfs_attr3_rmt_buf_space(mp); + unsigned int byte_cnt = xfs_attr3_rmt_buf_space(mp, attrns); byte_cnt = min(*valuelen, byte_cnt); - if (xfs_has_crc(mp)) { + if (xfs_attr3_rmt_has_header(mp, attrns)) { if (xfs_attr3_rmt_hdr_ok(src, owner, *offset, byte_cnt, bno)) { xfs_alert(mp, @@ -335,6 +389,7 @@ xfs_attr_rmtval_copyin( struct xfs_mount *mp, struct xfs_buf *bp, xfs_ino_t ino, + unsigned int attrns, unsigned int *offset, unsigned int *valuelen, uint8_t **src) @@ -347,12 +402,13 @@ xfs_attr_rmtval_copyin( ASSERT(len >= blksize); while (len > 0 && *valuelen > 0) { - unsigned int hdr_size; - unsigned int byte_cnt = xfs_attr3_rmt_buf_space(mp); + unsigned int hdr_size = 0; + unsigned int byte_cnt = xfs_attr3_rmt_buf_space(mp, attrns); byte_cnt = min(*valuelen, byte_cnt); - hdr_size = xfs_attr3_rmt_hdr_set(mp, dst, ino, *offset, - byte_cnt, bno); + if (xfs_attr3_rmt_has_header(mp, attrns)) + hdr_size = xfs_attr3_rmt_hdr_set(mp, dst, ino, *offset, + byte_cnt, bno); memcpy(dst + hdr_size, *src, byte_cnt); @@ -400,6 +456,7 @@ xfs_attr_rmtval_get( unsigned int blkcnt = args->rmtblkcnt; int i; unsigned int offset = 0; + const struct xfs_buf_ops *ops = xfs_attr3_remote_buf_ops(mp); trace_xfs_attr_rmtval_get(args); @@ -425,14 +482,15 @@ xfs_attr_rmtval_get( dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock); dblkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount); error = xfs_buf_read(mp->m_ddev_targp, dblkno, dblkcnt, - 0, &bp, &xfs_attr3_rmt_buf_ops); + 0, &bp, ops); if (xfs_metadata_is_sick(error)) xfs_dirattr_mark_sick(args->dp, XFS_ATTR_FORK); if (error) return error; error = xfs_attr_rmtval_copyout(mp, bp, args->dp, - args->owner, &offset, &valuelen, &dst); + args->owner, args->attr_filter, + &offset, &valuelen, &dst); xfs_buf_relse(bp); if (error) return error; @@ -460,7 +518,12 @@ xfs_attr_rmt_find_hole( unsigned int blkcnt; xfs_fileoff_t lfileoff = 0; - blkcnt = xfs_attr3_rmt_blocks(mp, args->rmtvaluelen); + /* + * Because CRC enable attributes have headers, we can't just do a + * straight byte to FSB conversion and have to take the header space + * into account. + */ + blkcnt = xfs_attr3_rmt_blocks(mp, args->attr_filter, args->rmtvaluelen); error = xfs_bmap_first_unused(args->trans, args->dp, blkcnt, &lfileoff, XFS_ATTR_FORK); if (error) @@ -519,10 +582,10 @@ xfs_attr_rmtval_set_value( error = xfs_buf_get(mp->m_ddev_targp, dblkno, dblkcnt, &bp); if (error) return error; - bp->b_ops = &xfs_attr3_rmt_buf_ops; + bp->b_ops = xfs_attr3_remote_buf_ops(mp); - xfs_attr_rmtval_copyin(mp, bp, args->owner, &offset, &valuelen, - &src); + xfs_attr_rmtval_copyin(mp, bp, args->owner, args->attr_filter, + &offset, &valuelen, &src); error = xfs_bwrite(bp); /* GROT: NOTE: synchronous write */ xfs_buf_relse(bp); diff --git a/fs/xfs/libxfs/xfs_attr_remote.h b/fs/xfs/libxfs/xfs_attr_remote.h index e3c6c7d774bf..2e2b3489a6cb 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.h +++ b/fs/xfs/libxfs/xfs_attr_remote.h @@ -6,12 +6,13 @@ #ifndef __XFS_ATTR_REMOTE_H__ #define __XFS_ATTR_REMOTE_H__ -unsigned int xfs_attr3_rmt_blocks(struct xfs_mount *mp, unsigned int attrlen); +unsigned int xfs_attr3_rmt_blocks(struct xfs_mount *mp, unsigned int attrns, + unsigned int attrlen); /* Number of rmt blocks needed to store the maximally sized attr value */ static inline unsigned int xfs_attr3_max_rmt_blocks(struct xfs_mount *mp) { - return xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX); + return xfs_attr3_rmt_blocks(mp, 0, XFS_XATTR_SIZE_MAX); } int xfs_attr_rmtval_get(struct xfs_da_args *args); @@ -23,4 +24,7 @@ int xfs_attr_rmt_find_hole(struct xfs_da_args *args); int xfs_attr_rmtval_set_value(struct xfs_da_args *args); int xfs_attr_rmtval_set_blk(struct xfs_attr_intent *attr); int xfs_attr_rmtval_find_space(struct xfs_attr_intent *attr); + +const struct xfs_buf_ops *xfs_attr3_remote_buf_ops(struct xfs_mount *mp); + #endif /* __XFS_ATTR_REMOTE_H__ */ diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index 4034530ad023..48bebcd1e226 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -892,7 +892,7 @@ struct xfs_attr3_rmt_hdr { #define XFS_ATTR3_RMT_CRC_OFF offsetof(struct xfs_attr3_rmt_hdr, rm_crc) -unsigned int xfs_attr3_rmt_buf_space(struct xfs_mount *mp); +unsigned int xfs_attr3_rmt_buf_space(struct xfs_mount *mp, unsigned int attrns); /* Number of bytes in a directory block. */ static inline unsigned int xfs_dir2_dirblock_bytes(struct xfs_sb *sbp) diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index e7efdb9ceaf3..59921c12ed15 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h @@ -26,6 +26,7 @@ extern const struct xfs_buf_ops xfs_agfl_buf_ops; extern const struct xfs_buf_ops xfs_agi_buf_ops; extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops; extern const struct xfs_buf_ops xfs_attr3_rmt_buf_ops; +extern const struct xfs_buf_ops xfs_attr3_rmtdxattr_buf_ops; extern const struct xfs_buf_ops xfs_bmbt_buf_ops; extern const struct xfs_buf_ops xfs_bnobt_buf_ops; extern const struct xfs_buf_ops xfs_cntbt_buf_ops; diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c index 2495ff76acec..d7a7f250d1c0 100644 --- a/fs/xfs/xfs_attr_inactive.c +++ b/fs/xfs/xfs_attr_inactive.c @@ -110,7 +110,7 @@ xfs_attr3_leaf_inactive( if (!name_rmt->valueblk) continue; - blkcnt = xfs_attr3_rmt_blocks(dp->i_mount, + blkcnt = xfs_attr3_rmt_blocks(dp->i_mount, entry->flags, be32_to_cpu(name_rmt->valuelen)); error = xfs_attr3_rmt_stale(dp, be32_to_cpu(name_rmt->valueblk), blkcnt); From patchwork Sun Dec 29 13:38:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13922695 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 13C7A1531C8 for ; Sun, 29 Dec 2024 13:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479555; cv=none; b=ftRwv/g1dI21rytBgwN9Z8Y/pIGON0182cQZnBOQT9P9rL0y9NwbLUL4TzX2LVvug7meGwVolq5LqixdQ0VLLkyiQ+9saTgKuy/zAM+MGD7jyUp8cdmdIilcSPUrUFyCzog6Nw5TWK4jk/rIZVQM5D2BgXW/MO2WPCxRx6QGVJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735479555; c=relaxed/simple; bh=Del7wvDAh5ABN5yFjGB0cyyNSTHG0xUCXAWBpHeao98=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L7KEj4EhE+1vX/qoHFYnZw+lVj61Yo+Pa1ZAT+eeREqzMp5v6rHQGuUus2X7lMPY+cFJ8Fr9tOyJ+kJPpQa8r9Pq5TvQccmgn7EbF5Sj530WZAyZ3RsMul71Ogex7/hJEKrFfiV++SVrYpICaEo1W/KiP3CSgf4vVOSaja3HsFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZVCe0D07; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZVCe0D07" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735479552; h=from:from:reply-to:subject:subject: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=PrI68dIX3adnQHGqL2xOG74NfjAO59Zy47fAa/jnZ7g=; b=ZVCe0D07t1jUzS2SQruwnxjlRePVif0J2JBI5Y3jZnen0Av8mYDvwva+XQVK/0UpMgRKnF EpMjWimwhFF6EBgOkYpqGItonpcQMocR84SsuUJVpjysFhN8zJ3KjVR9xZnO+9sVBrJQH0 y1WqDiTKONCa9ANxKiXd105Bua3fH2Q= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-hAtrcEeJN8qlB-XfITz4Nw-1; Sun, 29 Dec 2024 08:39:11 -0500 X-MC-Unique: hAtrcEeJN8qlB-XfITz4Nw-1 X-Mimecast-MFC-AGG-ID: hAtrcEeJN8qlB-XfITz4Nw Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-385e1fd40acso4082900f8f.3 for ; Sun, 29 Dec 2024 05:39:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735479550; x=1736084350; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PrI68dIX3adnQHGqL2xOG74NfjAO59Zy47fAa/jnZ7g=; b=ZJDpagBNN1JL1cEHu50aoSejw3dCaKYlvwsNpRIffUyTwvRJeieoTun13YzO4IKASN eSsdbbru0F6HKAtwZNXYvBGrLUe7g648xeWl2Me4mYqGxh+CKAGTjXu8Ik0m7I/1zEKX NiIbO61PRrnIbq8ow9Y+1gRwX+NU/Q9BPDFcdpKzf9WRIsQah+kuE6VD1nKxs5rdH5Ld 8T3yfitJkx0Ckf52jTqAy8LGeHA/q2tahk/+XgLtznh6TR9SE7sU20GVLsFd8cTXDy0i QI3TUDm7IWEip/wD0pT2Kqm/zrGesqiiQvzobLcQXhUajImlclOF2ssYnWnDr8qhBHdb lrsQ== X-Gm-Message-State: AOJu0YzxXmM6/OfhBlf8Ev5VTD2R7sFhBHbES99s9OJMQG23HqgV4hYI db2Rd1CnpUGJnzwimIanhPemPWim4I2fiysiqSgv3MJOhIctt6paJHnBiA+PWHE5e/Gzn7xTvC4 OITC6os8RyCikCcXBLe6onSqSF4uUH+udjm11PSL3t+OBdpdSzsTp20UeSuT5k+yT2Cf1SnyRuX wg9pK8/HhrXJyLP9dxYCFAL7ul2y7PwyblqvK4tJ+9 X-Gm-Gg: ASbGncvIj0tx6IbWT+IzLIPC+Pa2cbE+PZFHZNOG9UureaT9mEeXe+5SiIFjzJfmfY9 3KwsRAsC+VUn3yv8bHvjE8GLU4ETKdoCvFzeTivzPY0e0H4f9SJAZgTuakvVrICG1hsK3gE1+io 2LmA5yxIHagZNR66iN+EwRTB+g1KY3ibgSLLtJ3KZ59t83wJAoIrNKdFAEDxMQI/ZWHq/HUjuoy P+tD4EELeqX/Wd0lnV/SfM5tT0nnggXaERJx2qUYmPW5PVnaL4/ZnQ/w/JdZJAeYS9GJDJks3xS T+7R+gN4fu8fgg0= X-Received: by 2002:adf:cb06:0:b0:385:f44a:a3b with SMTP id ffacd0b85a97d-38a223f75d3mr18260990f8f.41.1735479550180; Sun, 29 Dec 2024 05:39:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFi4y4KSe8q15B9m2x4QC3C384q9W1DLADKpIpuYvnhlFc5y3oYcSttc5fs5ZzJRiD6pMAVdA== X-Received: by 2002:adf:cb06:0:b0:385:f44a:a3b with SMTP id ffacd0b85a97d-38a223f75d3mr18260977f8f.41.1735479549806; Sun, 29 Dec 2024 05:39:09 -0800 (PST) Received: from thinky.redhat.com (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474c2sm27093127f8f.55.2024.12.29.05.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 05:39:09 -0800 (PST) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn To: linux-xfs@vger.kernel.org Cc: djwong@kernel.org, david@fromorbit.com, hch@lst.de, Andrey Albershteyn Subject: [PATCH 14/14] xfs: enalbe XFS_SB_FEAT_INCOMPAT_DXATTR Date: Sun, 29 Dec 2024 14:38:36 +0100 Message-ID: <20241229133836.1194272-15-aalbersh@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241229133836.1194272-1-aalbersh@kernel.org> References: <20241229133350.1192387-1-aalbersh@kernel.org> <20241229133836.1194272-1-aalbersh@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Enabled directly mapped attribute data feature. This features includes on-disk format change in remote attribute leafs. Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 154458d72bc6..334ca8243b19 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -405,7 +405,8 @@ xfs_sb_has_ro_compat_feature( XFS_SB_FEAT_INCOMPAT_NREXT64 | \ XFS_SB_FEAT_INCOMPAT_EXCHRANGE | \ XFS_SB_FEAT_INCOMPAT_PARENT | \ - XFS_SB_FEAT_INCOMPAT_METADIR) + XFS_SB_FEAT_INCOMPAT_METADIR | \ + XFS_SB_FEAT_INCOMPAT_DXATTR) #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool