From patchwork Fri Oct 4 20:04:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822946 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA7061D8A0D; Fri, 4 Oct 2024 20:05:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072319; cv=none; b=Go0UCR+Q0BCzIHMXKlR4gUV/dfv4ilqkDkCAB+XkX/yT5UjIb+kxL9iWN2AmQlkbAcN6BJwvvayZr0IhujxfOgzazZ5WZFjX9FlGZxGDLQwqkPF4qOfZt9AI3YgN8Y6l5Yvx4nf3ALbM09rbkRypjCtNLP77G/Y6Xbt7YD+l5mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072319; c=relaxed/simple; bh=Q5r8578SDLV4SgqipaEHDdunhwK+7jrpc37aUEPk79k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C/0cPOMiFkBrRef1lQLWDMoXbB9szino5SDIDKCltHxsw97P160vqS6lZPg6qd2hIYK9Qu+Moxm5MgIfEJ46vWaaYVNQw6U/FDJFKiChTBEIgxMUd2L154DjZUJP0CkiEHV1SP30IFjzsODMzLI4VHbSvPKMHPtU7yPy/lKmf9M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Op1+bNr6; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=4H4jytF6; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Op1+bNr6; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=4H4jytF6; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Op1+bNr6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="4H4jytF6"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Op1+bNr6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="4H4jytF6" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AC88B1F7B4; Fri, 4 Oct 2024 20:05:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072315; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lg5HOi+E1Ye9/hwOAZzXYI4MTcQMFAmikAygyE8p4VU=; b=Op1+bNr6JPfn5aRSjSoNRW1paxpRFcudqI3TTm9jh2G02f5sPP5+qxcyIj4OCZ0SetFOcu 8PUEUqppjPi+ol9V0D42XgF+Udht9UJvIHFTz7PwpiKjetzpdSgaYanRvdPseijEndIHMn WCTIZP3Kmcnp0lMpbxPSftnXAs0vJJs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072315; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lg5HOi+E1Ye9/hwOAZzXYI4MTcQMFAmikAygyE8p4VU=; b=4H4jytF6FSbb6xjQyTJNSqyhN6o8l+T/U9uOhOp2mpmvMKz2kj17PX9wdFHk6d2KUQx02T kBzwnxB5dmZ56tCw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Op1+bNr6; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=4H4jytF6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072315; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lg5HOi+E1Ye9/hwOAZzXYI4MTcQMFAmikAygyE8p4VU=; b=Op1+bNr6JPfn5aRSjSoNRW1paxpRFcudqI3TTm9jh2G02f5sPP5+qxcyIj4OCZ0SetFOcu 8PUEUqppjPi+ol9V0D42XgF+Udht9UJvIHFTz7PwpiKjetzpdSgaYanRvdPseijEndIHMn WCTIZP3Kmcnp0lMpbxPSftnXAs0vJJs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072315; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lg5HOi+E1Ye9/hwOAZzXYI4MTcQMFAmikAygyE8p4VU=; b=4H4jytF6FSbb6xjQyTJNSqyhN6o8l+T/U9uOhOp2mpmvMKz2kj17PX9wdFHk6d2KUQx02T kBzwnxB5dmZ56tCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 75E3713883; Fri, 4 Oct 2024 20:05:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AbLqFntKAGfmRQAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:15 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 01/12] iomap: check if folio size is equal to FS block size Date: Fri, 4 Oct 2024 16:04:28 -0400 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: AC88B1F7B4 X-Spam-Score: -4.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.com:mid,suse.com:email]; FROM_EQ_ENVFROM(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO X-Spam-Level: From: Goldwyn Rodrigues Filesystems such as BTRFS use folio->private so that they receive a callback while releasing folios. Add check if folio size is same as filesystem block size while evaluating iomap_folio_state from folio->private. I am hoping this will be removed when all of btrfs code has moved to iomap and BTRFS uses iomap's subpage. Signed-off-by: Goldwyn Rodrigues --- fs/iomap/buffered-io.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index f420c53d86ac..ad656f501f38 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -43,6 +43,21 @@ struct iomap_folio_state { static struct bio_set iomap_ioend_bioset; +static inline struct iomap_folio_state *folio_state(struct folio *folio) +{ + struct inode *inode; + + if (folio->mapping && folio->mapping->host) + inode = folio->mapping->host; + else + return folio->private; + + if (i_blocks_per_folio(inode, folio) <= 1) + return NULL; + + return folio->private; +} + static inline bool ifs_is_fully_uptodate(struct folio *folio, struct iomap_folio_state *ifs) { @@ -72,7 +87,7 @@ static bool ifs_set_range_uptodate(struct folio *folio, static void iomap_set_range_uptodate(struct folio *folio, size_t off, size_t len) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); unsigned long flags; bool uptodate = true; @@ -123,7 +138,7 @@ static unsigned ifs_find_dirty_range(struct folio *folio, static unsigned iomap_find_dirty_range(struct folio *folio, u64 *range_start, u64 range_end) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); if (*range_start >= range_end) return 0; @@ -150,7 +165,7 @@ static void ifs_clear_range_dirty(struct folio *folio, static void iomap_clear_range_dirty(struct folio *folio, size_t off, size_t len) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); if (ifs) ifs_clear_range_dirty(folio, ifs, off, len); @@ -173,7 +188,7 @@ static void ifs_set_range_dirty(struct folio *folio, static void iomap_set_range_dirty(struct folio *folio, size_t off, size_t len) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); if (ifs) ifs_set_range_dirty(folio, ifs, off, len); @@ -182,7 +197,7 @@ static void iomap_set_range_dirty(struct folio *folio, size_t off, size_t len) static struct iomap_folio_state *ifs_alloc(struct inode *inode, struct folio *folio, unsigned int flags) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); unsigned int nr_blocks = i_blocks_per_folio(inode, folio); gfp_t gfp; @@ -234,7 +249,7 @@ static void ifs_free(struct folio *folio) static void iomap_adjust_read_range(struct inode *inode, struct folio *folio, loff_t *pos, loff_t length, size_t *offp, size_t *lenp) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); loff_t orig_pos = *pos; loff_t isize = i_size_read(inode); unsigned block_bits = inode->i_blkbits; @@ -292,7 +307,7 @@ static void iomap_adjust_read_range(struct inode *inode, struct folio *folio, static void iomap_finish_folio_read(struct folio *folio, size_t off, size_t len, int error) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); bool uptodate = !error; bool finished = true; @@ -568,7 +583,7 @@ EXPORT_SYMBOL_GPL(iomap_readahead); */ bool iomap_is_partially_uptodate(struct folio *folio, size_t from, size_t count) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); struct inode *inode = folio->mapping->host; unsigned first, last, i; @@ -1062,7 +1077,7 @@ static int iomap_write_delalloc_ifs_punch(struct inode *inode, * but not dirty. In that case it is necessary to punch * out such blocks to avoid leaking any delalloc blocks. */ - ifs = folio->private; + ifs = folio_state(folio); if (!ifs) return ret; @@ -1522,7 +1537,7 @@ EXPORT_SYMBOL_GPL(iomap_page_mkwrite); static void iomap_finish_folio_write(struct inode *inode, struct folio *folio, size_t len) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); WARN_ON_ONCE(i_blocks_per_folio(inode, folio) > 1 && !ifs); WARN_ON_ONCE(ifs && atomic_read(&ifs->write_bytes_pending) <= 0); @@ -1768,7 +1783,7 @@ static int iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, struct writeback_control *wbc, struct folio *folio, struct inode *inode, loff_t pos, unsigned len) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); size_t poff = offset_in_folio(folio, pos); int error; @@ -1807,7 +1822,7 @@ static int iomap_writepage_map_blocks(struct iomap_writepage_ctx *wpc, map_len = min_t(u64, dirty_len, wpc->iomap.offset + wpc->iomap.length - pos); - WARN_ON_ONCE(!folio->private && map_len < dirty_len); + WARN_ON_ONCE(!folio_state(folio) && map_len < dirty_len); switch (wpc->iomap.type) { case IOMAP_INLINE: @@ -1902,7 +1917,7 @@ static bool iomap_writepage_handle_eof(struct folio *folio, struct inode *inode, static int iomap_writepage_map(struct iomap_writepage_ctx *wpc, struct writeback_control *wbc, struct folio *folio) { - struct iomap_folio_state *ifs = folio->private; + struct iomap_folio_state *ifs = folio_state(folio); struct inode *inode = folio->mapping->host; u64 pos = folio_pos(folio); u64 end_pos = pos + folio_size(folio); From patchwork Fri Oct 4 20:04:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822947 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 194DC1D8DFC; Fri, 4 Oct 2024 20:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072322; cv=none; b=p+3vpPEZVtqXDymy4XPS4yE1RgaNO3kiwU6G8sViOdXRwAZksiBXA2qWfrh331sleYNNcbRbimNjcD8AgEjO/rpOrZQxGi8jW3RGH5JsHp5nCwTvjxIzfy56TLz7UeOM4Tlnne0AGeau/4B1J9wdME1JtaQVNRySLBJ9oze+kew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072322; c=relaxed/simple; bh=xFqljobrtngcrg1b+5fZW6YHgtWzCuFfuZzKFRW6P5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d5Y4bLjzXqkHjNtvtx3zf5xUwmTgTq/hjgyPdEx5y/a6GsXnDSnk7dSak2wAj3A6/uWRS9884o3P2/sGjLhmNwI8NrJqJJyYyzu8JiiGpdVBiwiQgmeBF61nhznuYmges3AZxbFdo/nI2uhcsExFWpOxpe8J8eFRYjzOJFDVmAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=L0kGluwx; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=01f9lBxJ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=L0kGluwx; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=01f9lBxJ; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="L0kGluwx"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="01f9lBxJ"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="L0kGluwx"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="01f9lBxJ" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 34B101F7B5; Fri, 4 Oct 2024 20:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072317; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WgZFS3GNTLFgCUJGHY6skAlfe6CVirllKIEvQP2Avek=; b=L0kGluwxIBnp8uFJLoJ0sMx7CehoxO4PP7PRSpSRFfzdZ8ndzvYguE2wotBs4Bt0lxtp/2 IjMQkWdX1GNbY7sQ0NLqQSFQItjCz0TSQ9faVne9YP1zVv22MdvJ/z6TsF5+bffERPWBr3 Y8XOOYvhcItqerS7wMBJB00uZFL/76k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072317; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WgZFS3GNTLFgCUJGHY6skAlfe6CVirllKIEvQP2Avek=; b=01f9lBxJJAaRbWMhZEJ9hdh/EZUy/SD7wB9dfLaY2eDxlMwfwj7l2CN7Nxp18tbX/G8zcv hEjjfN48rKbnOUBQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=L0kGluwx; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=01f9lBxJ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072317; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WgZFS3GNTLFgCUJGHY6skAlfe6CVirllKIEvQP2Avek=; b=L0kGluwxIBnp8uFJLoJ0sMx7CehoxO4PP7PRSpSRFfzdZ8ndzvYguE2wotBs4Bt0lxtp/2 IjMQkWdX1GNbY7sQ0NLqQSFQItjCz0TSQ9faVne9YP1zVv22MdvJ/z6TsF5+bffERPWBr3 Y8XOOYvhcItqerS7wMBJB00uZFL/76k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072317; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WgZFS3GNTLFgCUJGHY6skAlfe6CVirllKIEvQP2Avek=; b=01f9lBxJJAaRbWMhZEJ9hdh/EZUy/SD7wB9dfLaY2eDxlMwfwj7l2CN7Nxp18tbX/G8zcv hEjjfN48rKbnOUBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F25EB13883; Fri, 4 Oct 2024 20:05:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 3ZdKNXxKAGfpRQAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:16 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 02/12] iomap: Introduce iomap_read_folio_ops Date: Fri, 4 Oct 2024 16:04:29 -0400 Message-ID: <0bb16341dc43aa7102c1d959ebaecbf1b539e993.1728071257.git.rgoldwyn@suse.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 34B101F7B5 X-Spam-Score: -4.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,suse.de:dkim]; FROM_EQ_ENVFROM(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO X-Spam-Level: From: Goldwyn Rodrigues iomap_read_folio_ops provide additional functions to allocate or submit the bio. Filesystems such as btrfs have additional operations with bios such as verifying data checksums. Creating a bio submission hook allows the filesystem to process and verify the bio. Signed-off-by: Goldwyn Rodrigues --- block/fops.c | 4 ++-- fs/erofs/data.c | 4 ++-- fs/gfs2/aops.c | 4 ++-- fs/iomap/buffered-io.c | 31 ++++++++++++++++++++++++------- fs/xfs/xfs_aops.c | 4 ++-- fs/zonefs/file.c | 4 ++-- include/linux/iomap.h | 14 ++++++++++++-- 7 files changed, 46 insertions(+), 19 deletions(-) diff --git a/block/fops.c b/block/fops.c index 9825c1713a49..41cbd8e5db11 100644 --- a/block/fops.c +++ b/block/fops.c @@ -483,12 +483,12 @@ const struct address_space_operations def_blk_aops = { #else /* CONFIG_BUFFER_HEAD */ static int blkdev_read_folio(struct file *file, struct folio *folio) { - return iomap_read_folio(folio, &blkdev_iomap_ops); + return iomap_read_folio(folio, &blkdev_iomap_ops, NULL); } static void blkdev_readahead(struct readahead_control *rac) { - iomap_readahead(rac, &blkdev_iomap_ops); + iomap_readahead(rac, &blkdev_iomap_ops, NULL); } static int blkdev_map_blocks(struct iomap_writepage_ctx *wpc, diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 1b7eba38ba1e..335ce8be5894 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -347,12 +347,12 @@ int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, */ static int erofs_read_folio(struct file *file, struct folio *folio) { - return iomap_read_folio(folio, &erofs_iomap_ops); + return iomap_read_folio(folio, &erofs_iomap_ops, NULL); } static void erofs_readahead(struct readahead_control *rac) { - return iomap_readahead(rac, &erofs_iomap_ops); + return iomap_readahead(rac, &erofs_iomap_ops, NULL); } static sector_t erofs_bmap(struct address_space *mapping, sector_t block) diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 10d5acd3f742..3cc66b640cb9 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -451,7 +451,7 @@ static int gfs2_read_folio(struct file *file, struct folio *folio) if (!gfs2_is_jdata(ip) || (i_blocksize(inode) == PAGE_SIZE && !folio_buffers(folio))) { - error = iomap_read_folio(folio, &gfs2_iomap_ops); + error = iomap_read_folio(folio, &gfs2_iomap_ops, NULL); } else if (gfs2_is_stuffed(ip)) { error = stuffed_read_folio(ip, folio); } else { @@ -526,7 +526,7 @@ static void gfs2_readahead(struct readahead_control *rac) else if (gfs2_is_jdata(ip)) mpage_readahead(rac, gfs2_block_map); else - iomap_readahead(rac, &gfs2_iomap_ops); + iomap_readahead(rac, &gfs2_iomap_ops, NULL); } /** diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index ad656f501f38..71370bbe466c 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -341,6 +341,7 @@ struct iomap_readpage_ctx { bool cur_folio_in_bio; struct bio *bio; struct readahead_control *rac; + const struct iomap_read_folio_ops *ops; }; /** @@ -424,8 +425,12 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter, gfp_t orig_gfp = gfp; unsigned int nr_vecs = DIV_ROUND_UP(length, PAGE_SIZE); - if (ctx->bio) - submit_bio(ctx->bio); + if (ctx->bio) { + if (ctx->ops && ctx->ops->submit_io) + ctx->ops->submit_io(iter->inode, ctx->bio); + else + submit_bio(ctx->bio); + } if (ctx->rac) /* same as readahead_gfp_mask */ gfp |= __GFP_NORETRY | __GFP_NOWARN; @@ -475,7 +480,8 @@ 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(struct folio *folio, const struct iomap_ops *ops, + const struct iomap_read_folio_ops *read_folio_ops) { struct iomap_iter iter = { .inode = folio->mapping->host, @@ -484,6 +490,7 @@ int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops) }; struct iomap_readpage_ctx ctx = { .cur_folio = folio, + .ops = read_folio_ops, }; int ret; @@ -493,7 +500,10 @@ int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops) iter.processed = iomap_read_folio_iter(&iter, &ctx); if (ctx.bio) { - submit_bio(ctx.bio); + if (ctx.ops->submit_io) + ctx.ops->submit_io(iter.inode, ctx.bio); + else + submit_bio(ctx.bio); WARN_ON_ONCE(!ctx.cur_folio_in_bio); } else { WARN_ON_ONCE(ctx.cur_folio_in_bio); @@ -538,6 +548,7 @@ static loff_t iomap_readahead_iter(const struct iomap_iter *iter, * iomap_readahead - Attempt to read pages from a file. * @rac: Describes the pages to be read. * @ops: The operations vector for the filesystem. + * @read_folio_ops: Function hooks for filesystems for special bio submissions * * This function is for filesystems to call to implement their readahead * address_space operation. @@ -549,7 +560,8 @@ static loff_t iomap_readahead_iter(const struct iomap_iter *iter, * function is called with memalloc_nofs set, so allocations will not cause * the filesystem to be reentered. */ -void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops) +void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops, + const struct iomap_read_folio_ops *read_folio_ops) { struct iomap_iter iter = { .inode = rac->mapping->host, @@ -558,6 +570,7 @@ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops) }; struct iomap_readpage_ctx ctx = { .rac = rac, + .ops = read_folio_ops, }; trace_iomap_readahead(rac->mapping->host, readahead_count(rac)); @@ -565,8 +578,12 @@ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops) while (iomap_iter(&iter, ops) > 0) iter.processed = iomap_readahead_iter(&iter, &ctx); - if (ctx.bio) - submit_bio(ctx.bio); + if (ctx.bio) { + if (ctx.ops && ctx.ops->submit_io) + ctx.ops->submit_io(iter.inode, ctx.bio); + else + submit_bio(ctx.bio); + } if (ctx.cur_folio) { if (!ctx.cur_folio_in_bio) folio_unlock(ctx.cur_folio); diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 6dead20338e2..9a3221d738bd 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -517,14 +517,14 @@ xfs_vm_read_folio( struct file *unused, struct folio *folio) { - return iomap_read_folio(folio, &xfs_read_iomap_ops); + return iomap_read_folio(folio, &xfs_read_iomap_ops, NULL); } STATIC void xfs_vm_readahead( struct readahead_control *rac) { - iomap_readahead(rac, &xfs_read_iomap_ops); + iomap_readahead(rac, &xfs_read_iomap_ops, NULL); } static int diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c index 3b103715acc9..bf8db1ddd761 100644 --- a/fs/zonefs/file.c +++ b/fs/zonefs/file.c @@ -112,12 +112,12 @@ static const struct iomap_ops zonefs_write_iomap_ops = { static int zonefs_read_folio(struct file *unused, struct folio *folio) { - return iomap_read_folio(folio, &zonefs_read_iomap_ops); + return iomap_read_folio(folio, &zonefs_read_iomap_ops, NULL); } static void zonefs_readahead(struct readahead_control *rac) { - iomap_readahead(rac, &zonefs_read_iomap_ops); + iomap_readahead(rac, &zonefs_read_iomap_ops, NULL); } /* diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 6fc1c858013d..5b775213920e 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -256,14 +256,24 @@ static inline const struct iomap *iomap_iter_srcmap(const struct iomap_iter *i) return &i->iomap; } +struct iomap_read_folio_ops { + /* + * Optional, allows the filesystem to perform a custom submission of + * bio, such as csum calculations or multi-device bio split + */ + void (*submit_io)(struct inode *inode, struct bio *bio); +}; + ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from, const struct iomap_ops *ops); int iomap_file_buffered_write_punch_delalloc(struct inode *inode, struct iomap *iomap, loff_t pos, loff_t length, ssize_t written, int (*punch)(struct inode *inode, loff_t pos, loff_t length)); -int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops); -void iomap_readahead(struct readahead_control *, const struct iomap_ops *ops); +int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops, + const struct iomap_read_folio_ops *); +void iomap_readahead(struct readahead_control *, const struct iomap_ops *ops, + const struct iomap_read_folio_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); bool iomap_release_folio(struct folio *folio, gfp_t gfp_flags); From patchwork Fri Oct 4 20:04:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822948 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C51901D90B7; Fri, 4 Oct 2024 20:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072323; cv=none; b=r5vuyYng44P++BBlKabHU+wMS1oivjkWWEoZnlgzUF+75DxLqY333uj7uDhPttENCOwANJ8XiJExE8S+CNKNL/c9bOYxgCGuShsXuwu5fSd8rIF/HUM+x7VjRi+t7Su6jf98eJPvT2RjKNriru4mnrEwhg5x+PzL/++wri/mp9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072323; c=relaxed/simple; bh=Fpt4YPr87mHv4JmGMIh8GwlBLkDcdX+nghxJNit8v1c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ihbd/iJ+a0G3LQkRtdxNgPZpabZivk89INC9QfiIT1dWSzA/1PMb5N3zXMmw3QM86mDh+/x9TNnUXIK+3y3MEcoHxJerfn1yEFL115UA9a4D1rO78UybvMMb6+vsCZI2NCnPMYn4oB3h1DkkJ3J7jz5JYvK96ZKxBgFl5c5dZOA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=NY3PHX1f; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=U5J8L0C/; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=i+/OU30k; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=ZZFMxc1w; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="NY3PHX1f"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="U5J8L0C/"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="i+/OU30k"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ZZFMxc1w" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E958A21D52; Fri, 4 Oct 2024 20:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072320; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NAlPD+GUVZwmk0Pd7GZDO3MjGJpMAgMWe/gHTxltMc4=; b=NY3PHX1fxGqdEPfxRNxTTdl2Z5eDzMB9vdY/F6Rofg2iEMcdcJJ010NaC1zcqmVYgCYQcY lGHeY5+kWn07Wk2Gk8P76Khsx10E0TVHq4KeZuSgRNLvwTzG9fks1gqnnehXVqYMIIL8Xu Up6wzKp/h7mq9GORpk8DG21fgX/0NR4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072320; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NAlPD+GUVZwmk0Pd7GZDO3MjGJpMAgMWe/gHTxltMc4=; b=U5J8L0C/OOjtiGNDqEz+CQiAuEENL3C1HWRiMZoJeG8ke2anWSpZenOI1v5hGeXUsBY9G0 aFQDLt4jGExR8aAw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072319; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NAlPD+GUVZwmk0Pd7GZDO3MjGJpMAgMWe/gHTxltMc4=; b=i+/OU30ka0A3dgc6s83GVNrbZMOhCiRCtvB762K6TXVVcsyqqUBRuLc648DMPO2W4xHAkV AtrTefCef/OQa/AO7rAij79LRdhS7l0oTRjduI6o8bwCe20b1eUN9cwwpfiPxm1r5jeyQh iGHm2h92iuhLbeHCr6d9gOe3CIeRqJ8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072319; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NAlPD+GUVZwmk0Pd7GZDO3MjGJpMAgMWe/gHTxltMc4=; b=ZZFMxc1wy6b6IWsIHaauxn4gzYgTbOWA2k9fscrKps3gAfn+98/QFnyDzaXzR8ZANzamqV wKYW9DbbUOHDg4Dw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7F08613883; Fri, 4 Oct 2024 20:05:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ul+5En9KAGftRQAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:19 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 03/12] iomap: add bioset in iomap_read_folio_ops for filesystems to use own bioset Date: Fri, 4 Oct 2024 16:04:30 -0400 Message-ID: <95262994f8ba468ab26f1e855224c54c2a439669.1728071257.git.rgoldwyn@suse.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Score: -3.80 X-Spamd-Result: default: False [-3.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Level: From: Goldwyn Rodrigues Allocate the bio from the bioset provided in iomap_read_folio_ops. If no bioset is provided, fs_bio_set is used which is the standard bioset for filesystems. Signed-off-by: Goldwyn Rodrigues --- fs/iomap/buffered-io.c | 20 ++++++++++++++------ include/linux/iomap.h | 6 ++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 71370bbe466c..d007b4a8307c 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -421,6 +421,7 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter, if (!ctx->bio || bio_end_sector(ctx->bio) != sector || !bio_add_folio(ctx->bio, folio, plen, poff)) { + struct bio_set *bioset; gfp_t gfp = mapping_gfp_constraint(folio->mapping, GFP_KERNEL); gfp_t orig_gfp = gfp; unsigned int nr_vecs = DIV_ROUND_UP(length, PAGE_SIZE); @@ -434,17 +435,24 @@ 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); + + if (ctx->ops && ctx->ops->bio_set) + bioset = ctx->ops->bio_set; + else + bioset = &fs_bio_set; + + ctx->bio = bio_alloc_bioset(iomap->bdev, bio_max_segs(nr_vecs), + REQ_OP_READ, gfp, 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); - } + if (!ctx->bio) + ctx->bio = bio_alloc_bioset(iomap->bdev, 1, REQ_OP_READ, + orig_gfp, bioset); + if (ctx->rac) ctx->bio->bi_opf |= REQ_RAHEAD; ctx->bio->bi_iter.bi_sector = sector; diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 5b775213920e..f876d16353c6 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -262,6 +262,12 @@ struct iomap_read_folio_ops { * bio, such as csum calculations or multi-device bio split */ void (*submit_io)(struct inode *inode, struct bio *bio); + + /* + * Optional, allows filesystem to specify own bio_set, so new bio's + * can be allocated from the provided bio_set. + */ + struct bio_set *bio_set; }; ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from, From patchwork Fri Oct 4 20:04:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822949 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE0541D9586; Fri, 4 Oct 2024 20:05:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072330; cv=none; b=CKAtAjpn7EwOZxOhCA0RxIpLfMWJ5v4fkPeb86wprNqcsAwMpwCSTBPMSos4c77B6PGay//0cUg7kUwsmiJ0PGjOQZ4xS8l2KpEbn/9t4Lh4XQ8JGIq193L/B44MB/sgvLGKjnqeg0glJR7efFQiMxxvLquuT/9zATp1DDec4Mw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072330; c=relaxed/simple; bh=Ylmf39fNl3rrw2QwvEVjUjbX63Vqipfj3lQsGTZMzO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nXr43eux4QXPdHBV6IKR8Q2k9ydnI1uzO++8QfwLyuzzM1jnON+8V5/VfT34lQuv5XWUCghcdvpy2NKIix/yi23GJ6Gh6goNn8i/+EF3z3kBFmkJItlFvlpKOZhv4Db/1g4WBYV8chFxwvAMNYpGuaNo5Aep/lo9gWo3JVfpzas= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=mY1gxnA2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=A4GCrkmm; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=mY1gxnA2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=A4GCrkmm; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mY1gxnA2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="A4GCrkmm"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mY1gxnA2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="A4GCrkmm" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1D43521D52; Fri, 4 Oct 2024 20:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072327; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l912tuLUa+IEmsUS77BR6e/XwLT4qu25ITIvaRN17ZQ=; b=mY1gxnA2539lhMupkqYNLcSvRi3uQ+PN+4kFcLwb/bC9XMwZOG8NPLs75tn2XEj2Hk1qsm QqJ/BxMTPhUETJ0kXvIfFyyDKiK3tcEy0ZfLFnMjOCuWcOJrK2cAUNgkp3Y12JbnjXB/3r aO7zdHlYqRPDlselZOdjunvkVh9Lh8E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072327; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l912tuLUa+IEmsUS77BR6e/XwLT4qu25ITIvaRN17ZQ=; b=A4GCrkmmS6cczQRr8xkq+RpeLX1Z0Cp+FFW5V3Q+8Z/qT0BObKUEPR4XEoa0H0PghnnsJ8 caBMqv0sxNNHS9DA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=mY1gxnA2; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=A4GCrkmm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072327; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l912tuLUa+IEmsUS77BR6e/XwLT4qu25ITIvaRN17ZQ=; b=mY1gxnA2539lhMupkqYNLcSvRi3uQ+PN+4kFcLwb/bC9XMwZOG8NPLs75tn2XEj2Hk1qsm QqJ/BxMTPhUETJ0kXvIfFyyDKiK3tcEy0ZfLFnMjOCuWcOJrK2cAUNgkp3Y12JbnjXB/3r aO7zdHlYqRPDlselZOdjunvkVh9Lh8E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072327; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l912tuLUa+IEmsUS77BR6e/XwLT4qu25ITIvaRN17ZQ=; b=A4GCrkmmS6cczQRr8xkq+RpeLX1Z0Cp+FFW5V3Q+8Z/qT0BObKUEPR4XEoa0H0PghnnsJ8 caBMqv0sxNNHS9DA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A772113883; Fri, 4 Oct 2024 20:05:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 3kTQHIZKAGfzRQAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:26 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 04/12] iomap: include iomap_read_end_io() in header Date: Fri, 4 Oct 2024 16:04:31 -0400 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 1D43521D52 X-Spam-Level: X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid,suse.de:dkim]; FROM_EQ_ENVFROM(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.01 X-Spam-Flag: NO From: Goldwyn Rodrigues iomap_read_end_io() will be used BTRFS after it has completed the reads to handle control back to iomap to finish reads on all folios. Signed-off-by: Goldwyn Rodrigues --- fs/iomap/buffered-io.c | 2 +- include/linux/iomap.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index d007b4a8307c..0e682ff84e4a 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -326,7 +326,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; diff --git a/include/linux/iomap.h b/include/linux/iomap.h index f876d16353c6..7b757bea8455 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -280,6 +280,7 @@ int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops, const struct iomap_read_folio_ops *); void iomap_readahead(struct readahead_control *, const struct iomap_ops *ops, const struct iomap_read_folio_ops *); +void iomap_read_end_io(struct bio *bio); 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); bool iomap_release_folio(struct folio *folio, gfp_t gfp_flags); From patchwork Fri Oct 4 20:04:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822950 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94FFC1D959E; Fri, 4 Oct 2024 20:05:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072333; cv=none; b=adtKQPMPwuYA2HLCgLpbPappaaklcxDMxboLYXEYkPeHQPJ3bK2bDonpUgRFLZZQcvjZwdwx4wvulgUm8tc6ceVUumKKDpp7oZxd/R32x3/dBLVT94Na4dBTqktKrMU+tpRPFdO/3Fxg6DPAiaauifMnQ3CzSb2PPoMWuSWV+xs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072333; c=relaxed/simple; bh=8DErGaIXJvy5ZwaYqrQe+6UwFIYJEFsf5yz4BYudoDI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cjwgqDC/ppqwXcJmi+yDOyLkgvZyZadqzvbJFIt+wypu0bf3Z53EsrOwS7KqhW4RYsSq/vIkJsnVPrqnI304pqxTcdQUcfLtFeNf+yL/hTpfXoo+AlpAY1MkmkIky99V9C8O+s+y2QUbz+f10lksmlyPyKN668plWKdhyT+9QPQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=od0eDtF0; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=WGxmOx1k; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=od0eDtF0; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=WGxmOx1k; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="od0eDtF0"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="WGxmOx1k"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="od0eDtF0"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="WGxmOx1k" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A77DF21D73; Fri, 4 Oct 2024 20:05:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072329; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+AQJHqCZURz5AYFAqbxGpLiNA1wJE6CG19ccDyjREC8=; b=od0eDtF0D46QMZlwDrJz0OxL4/Xm3CEIOpepatGF4NtJfxuK7SvZ1nUT/JtpOJYSYq+qGF mklhzRQZgmu6jsSHb+GofpEQFTd7YjU9pCMJ+79Z7tFld+Si2nbnfKj5ZeLVrG1Bcjdxfm csls7wgtZvmXkUpfTDIUMHjhTazlvvM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072329; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+AQJHqCZURz5AYFAqbxGpLiNA1wJE6CG19ccDyjREC8=; b=WGxmOx1kE8xxx08MFhwmQFUTyhrXDWkx1KAQ8UDpesILGcDfKC6s0ct5I4ajAajNUUh6fK M4SisfIWCrtcXWDA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=od0eDtF0; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=WGxmOx1k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072329; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+AQJHqCZURz5AYFAqbxGpLiNA1wJE6CG19ccDyjREC8=; b=od0eDtF0D46QMZlwDrJz0OxL4/Xm3CEIOpepatGF4NtJfxuK7SvZ1nUT/JtpOJYSYq+qGF mklhzRQZgmu6jsSHb+GofpEQFTd7YjU9pCMJ+79Z7tFld+Si2nbnfKj5ZeLVrG1Bcjdxfm csls7wgtZvmXkUpfTDIUMHjhTazlvvM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072329; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+AQJHqCZURz5AYFAqbxGpLiNA1wJE6CG19ccDyjREC8=; b=WGxmOx1kE8xxx08MFhwmQFUTyhrXDWkx1KAQ8UDpesILGcDfKC6s0ct5I4ajAajNUUh6fK M4SisfIWCrtcXWDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 55D3313883; Fri, 4 Oct 2024 20:05:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 74axCIlKAGf2RQAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:29 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 05/12] iomap: Introduce IOMAP_ENCODED Date: Fri, 4 Oct 2024 16:04:32 -0400 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: A77DF21D73 X-Spam-Level: X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid,suse.de:dkim]; FROM_EQ_ENVFROM(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.01 X-Spam-Flag: NO From: Goldwyn Rodrigues An encoded extent must be read completely. Make the bio just as a regular bio and let filesystem deal with the rest of the extent. A new bio must be created if a new iomap is returned. The filesystem must be informed that the bio to be read is encoded and the offset from which the encoded extent starts. So, pass the iomap associated with the bio while calling submit_io. Save the previous iomap (associated with the bio being submitted) in prev in order to submit when the iomap changes. Signed-off-by: Goldwyn Rodrigues --- fs/iomap/buffered-io.c | 17 ++++++++++------- include/linux/iomap.h | 11 +++++++++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 0e682ff84e4a..4c734899a8e5 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -378,12 +378,13 @@ static inline bool iomap_block_needs_zeroing(const struct iomap_iter *iter, { const struct iomap *srcmap = iomap_iter_srcmap(iter); - return srcmap->type != IOMAP_MAPPED || + return (srcmap->type != IOMAP_MAPPED && + srcmap->type != IOMAP_ENCODED) || (srcmap->flags & IOMAP_F_NEW) || pos >= i_size_read(iter->inode); } -static loff_t iomap_readpage_iter(const struct iomap_iter *iter, +static loff_t iomap_readpage_iter(struct iomap_iter *iter, struct iomap_readpage_ctx *ctx, loff_t offset) { const struct iomap *iomap = &iter->iomap; @@ -419,6 +420,7 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter, sector = iomap_sector(iomap, pos); if (!ctx->bio || + (iomap->type & IOMAP_ENCODED && iomap->offset != iter->prev.offset) || bio_end_sector(ctx->bio) != sector || !bio_add_folio(ctx->bio, folio, plen, poff)) { struct bio_set *bioset; @@ -428,10 +430,11 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter, if (ctx->bio) { if (ctx->ops && ctx->ops->submit_io) - ctx->ops->submit_io(iter->inode, ctx->bio); + ctx->ops->submit_io(iter->inode, ctx->bio, &iter->prev); else submit_bio(ctx->bio); } + iter->prev = iter->iomap; if (ctx->rac) /* same as readahead_gfp_mask */ gfp |= __GFP_NORETRY | __GFP_NOWARN; @@ -470,7 +473,7 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter, return pos - orig_pos + plen; } -static loff_t iomap_read_folio_iter(const struct iomap_iter *iter, +static loff_t iomap_read_folio_iter(struct iomap_iter *iter, struct iomap_readpage_ctx *ctx) { struct folio *folio = ctx->cur_folio; @@ -509,7 +512,7 @@ int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops, if (ctx.bio) { if (ctx.ops->submit_io) - ctx.ops->submit_io(iter.inode, ctx.bio); + ctx.ops->submit_io(iter.inode, ctx.bio, &iter.prev); else submit_bio(ctx.bio); WARN_ON_ONCE(!ctx.cur_folio_in_bio); @@ -527,7 +530,7 @@ int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops, } EXPORT_SYMBOL_GPL(iomap_read_folio); -static loff_t iomap_readahead_iter(const struct iomap_iter *iter, +static loff_t iomap_readahead_iter(struct iomap_iter *iter, struct iomap_readpage_ctx *ctx) { loff_t length = iomap_length(iter); @@ -588,7 +591,7 @@ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops, if (ctx.bio) { if (ctx.ops && ctx.ops->submit_io) - ctx.ops->submit_io(iter.inode, ctx.bio); + ctx.ops->submit_io(iter.inode, ctx.bio, &iter.prev); else submit_bio(ctx.bio); } diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 7b757bea8455..a5cf00a01f23 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -30,6 +30,7 @@ struct vm_fault; #define IOMAP_MAPPED 2 /* blocks allocated at @addr */ #define IOMAP_UNWRITTEN 3 /* blocks allocated at @addr in unwritten state */ #define IOMAP_INLINE 4 /* data inline in the inode */ +#define IOMAP_ENCODED 5 /* data encoded, R/W whole extent */ /* * Flags reported by the file system from iomap_begin: @@ -107,6 +108,8 @@ struct iomap { static inline sector_t iomap_sector(const struct iomap *iomap, loff_t pos) { + if (iomap->type & IOMAP_ENCODED) + return iomap->addr; return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT; } @@ -217,9 +220,13 @@ struct iomap_iter { loff_t pos; u64 len; s64 processed; + unsigned type; unsigned flags; struct iomap iomap; - struct iomap srcmap; + union { + struct iomap srcmap; + struct iomap prev; + }; void *private; }; @@ -261,7 +268,7 @@ struct iomap_read_folio_ops { * Optional, allows the filesystem to perform a custom submission of * bio, such as csum calculations or multi-device bio split */ - void (*submit_io)(struct inode *inode, struct bio *bio); + void (*submit_io)(struct inode *inode, struct bio *bio, const struct iomap *iomap); /* * Optional, allows filesystem to specify own bio_set, so new bio's From patchwork Fri Oct 4 20:04:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822951 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C31B1DDC32; Fri, 4 Oct 2024 20:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072335; cv=none; b=jkEoEMxiRcpHQZPkG6Bq1jfIsHi934+dEOcGRUNzvCxMkBFKY4c2F+iNf0qwUpFp1PLLHTyS1sRqVdKLFJ1s40ePU/GrK1XfOh4GeSUgPSwwMpXvDSQXwfqLUuLKyinAkQo/E1QE4YBhL71sR+TARwJYni8sZJ7uNda2W5CExtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072335; c=relaxed/simple; bh=i45K8c1WWp5r4r6Kd7srRGmTePqEUfFgPSQuFbh8ukk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LeGoo4+VFfE/9Svh+KdO/P+OH7nZ5l+YiWHzKVLSWSJSj4RjGDOZHihIZI+fH5thvagSWeeRTdslHQA3tOnHR+dec9eUCBV3DdUur4rkqTn4pemhTwXKxGDGyPTfE1Y+12nn4imwcKwDR0MPK73JaBvJt3JGmZQiGgKAnzoIQe4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=K6fP5qwc; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=rG0rJpLB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=K6fP5qwc; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=rG0rJpLB; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="K6fP5qwc"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="rG0rJpLB"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="K6fP5qwc"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="rG0rJpLB" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 85ECF1F7B3; Fri, 4 Oct 2024 20:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072332; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NBLypl0tLX7MbtwoiCqucZErfjtV7PifuXn4xwONsDw=; b=K6fP5qwc5/hNLZPMfJCnF50MR2/vY9eJU0tyZgPvMO1Vz7oztiqbhi8BF7PdkUhYswE0XZ g1AoTe3p6PUa8fgisLoO1L24mkLlWCfTKHHFeBOFidX7FZxo7EcfXwHfNnorButGz5dMMq 1cUTOZhy/l6RDG0XnYsIhpsnMyOar/o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072332; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NBLypl0tLX7MbtwoiCqucZErfjtV7PifuXn4xwONsDw=; b=rG0rJpLBNC+/le/x8aJVGx9Fi989CTdQ7BaxgaWOPoxvbC5O29bg7K/PTFyp/YCladNfz1 CdyvmFXRvlWKLUCA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072332; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NBLypl0tLX7MbtwoiCqucZErfjtV7PifuXn4xwONsDw=; b=K6fP5qwc5/hNLZPMfJCnF50MR2/vY9eJU0tyZgPvMO1Vz7oztiqbhi8BF7PdkUhYswE0XZ g1AoTe3p6PUa8fgisLoO1L24mkLlWCfTKHHFeBOFidX7FZxo7EcfXwHfNnorButGz5dMMq 1cUTOZhy/l6RDG0XnYsIhpsnMyOar/o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072332; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NBLypl0tLX7MbtwoiCqucZErfjtV7PifuXn4xwONsDw=; b=rG0rJpLBNC+/le/x8aJVGx9Fi989CTdQ7BaxgaWOPoxvbC5O29bg7K/PTFyp/YCladNfz1 CdyvmFXRvlWKLUCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1C23A13883; Fri, 4 Oct 2024 20:05:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id j241NotKAGf7RQAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:31 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 06/12] iomap: Introduce read_inline() function hook Date: Fri, 4 Oct 2024 16:04:33 -0400 Message-ID: <8147ae0a45b9851eacad4e8f5a71b7997c23bdd0.1728071257.git.rgoldwyn@suse.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-3.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -3.80 X-Spam-Flag: NO From: Goldwyn Rodrigues Introduce read_inline() function hook for reading inline extents. This is performed for filesystems such as btrfs which may compress the data in the inline extents. This is added in struct iomap_folio_ops, since folio is available at this point. Signed-off-by: Goldwyn Rodrigues --- fs/iomap/buffered-io.c | 12 +++++++++--- include/linux/iomap.h | 7 +++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 4c734899a8e5..ef805730125a 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -359,6 +359,7 @@ static int iomap_read_inline_data(const struct iomap_iter *iter, const struct iomap *iomap = iomap_iter_srcmap(iter); size_t size = i_size_read(iter->inode) - iomap->offset; size_t offset = offset_in_folio(folio, iomap->offset); + int ret = 0; if (folio_test_uptodate(folio)) return 0; @@ -368,9 +369,14 @@ static int iomap_read_inline_data(const struct iomap_iter *iter, if (offset > 0) ifs_alloc(iter->inode, folio, iter->flags); - folio_fill_tail(folio, offset, iomap->inline_data, size); - iomap_set_range_uptodate(folio, offset, folio_size(folio) - offset); - return 0; + if (iomap->folio_ops && iomap->folio_ops->read_inline) + ret = iomap->folio_ops->read_inline(iomap, folio); + else + folio_fill_tail(folio, offset, iomap->inline_data, size); + + if (!ret) + iomap_set_range_uptodate(folio, offset, folio_size(folio) - offset); + return ret; } static inline bool iomap_block_needs_zeroing(const struct iomap_iter *iter, diff --git a/include/linux/iomap.h b/include/linux/iomap.h index a5cf00a01f23..82dabc0369cd 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -163,6 +163,13 @@ struct iomap_folio_ops { * locked by the iomap code. */ bool (*iomap_valid)(struct inode *inode, const struct iomap *iomap); + + /* + * Custom read_inline function for filesystem such as btrfs + * that may store data in compressed form. + */ + + int (*read_inline)(const struct iomap *iomap, struct folio *folio); }; /* From patchwork Fri Oct 4 20:04:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822952 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CA6C1DF72C; Fri, 4 Oct 2024 20:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072338; cv=none; b=BCGGq2VF0IzE+WdFxk5KTbms35o8xR9oOWvcYpBxpV0rLow3dGQAA/hVVwqD8qHb9i5MKb35u2TEursQYm+ceWw4g+A2x1bY1P7EBMk5lWVMd4YQ47XlsbIS812/+JXjd5SpgyBOZapa6N6cJZc1XwtkQuVHXWJG4N9v+QTnne0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072338; c=relaxed/simple; bh=qNoTbfrD2fiD/WYead95JSHx65XyGde9xKUbHYGUgKI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KQ7H6Gvud5Le3SuZqGEJMidLLxmZP29MRolVeG11cKFRIcZVeq6fp0O/+psAfG4lRRwcmQF3am0ncpWeWWIjnVklEfxjVdRBbGwwdocU//HYnLycwUQklcQx32KJRvzcrHBJJuvtQ6lH+e55/5nP4AC/ibSK6qtHq+5bJAKnLbY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MP6wujyD; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=N6xnXhOB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MP6wujyD; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=N6xnXhOB; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MP6wujyD"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="N6xnXhOB"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MP6wujyD"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="N6xnXhOB" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B078321D52; Fri, 4 Oct 2024 20:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072335; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aGPkM6gewJ/SPePSMUm19utfX+Gmzgakh66Hi9khGMI=; b=MP6wujyD470A8pflac8i3UVxRtS1pIqy/czN5/jjAPF632/m5xhw8KC2n9PrPDqpmxP+88 DpkJcll41aAXOnKRYxJVGW/FP812TksEvqK+p6iXG+wEQ0orFQHF6H0qvZfsmsAgiRJ2jE 7Axbuq65pNegZlDVfh5HegQHCAJUWgY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072335; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aGPkM6gewJ/SPePSMUm19utfX+Gmzgakh66Hi9khGMI=; b=N6xnXhOBAi/PO7CNycPa9RcfmOLx/Ubla876sjvE3cJ8+NSGkxAC5/JRRcyzk9nhFCDxio S+xlf0+jjK399LAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072335; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aGPkM6gewJ/SPePSMUm19utfX+Gmzgakh66Hi9khGMI=; b=MP6wujyD470A8pflac8i3UVxRtS1pIqy/czN5/jjAPF632/m5xhw8KC2n9PrPDqpmxP+88 DpkJcll41aAXOnKRYxJVGW/FP812TksEvqK+p6iXG+wEQ0orFQHF6H0qvZfsmsAgiRJ2jE 7Axbuq65pNegZlDVfh5HegQHCAJUWgY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072335; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aGPkM6gewJ/SPePSMUm19utfX+Gmzgakh66Hi9khGMI=; b=N6xnXhOBAi/PO7CNycPa9RcfmOLx/Ubla876sjvE3cJ8+NSGkxAC5/JRRcyzk9nhFCDxio S+xlf0+jjK399LAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2D40413883; Fri, 4 Oct 2024 20:05:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id dhaFOo5KAGf/RQAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:34 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 07/12] btrfs: btrfs_em_to_iomap() to convert em to iomap Date: Fri, 4 Oct 2024 16:04:34 -0400 Message-ID: <23762f818bfb84bd38b4ad0e803588dc140cd14a.1728071257.git.rgoldwyn@suse.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-3.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -3.80 X-Spam-Flag: NO From: Goldwyn Rodrigues btrfs_em_to_iomap() converts and extent map into passed argument struct iomap. It makes sure the information is in multiple of sectorsize block. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/extent_io.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index cb0a39370d30..7f40c2b8bfb8 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "extent_io.h" #include "extent-io-tree.h" #include "extent_map.h" @@ -900,6 +901,35 @@ void clear_folio_extent_mapped(struct folio *folio) folio_detach_private(folio); } +static void btrfs_em_to_iomap(struct inode *inode, + struct extent_map *em, struct iomap *iomap, + loff_t sector_pos, bool write) +{ + struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); + + if (!btrfs_is_data_reloc_root(BTRFS_I(inode)->root) && + em->flags & EXTENT_FLAG_PINNED) { + iomap->type = IOMAP_UNWRITTEN; + iomap->addr = extent_map_block_start(em); + } else if (em->disk_bytenr == EXTENT_MAP_INLINE) { + iomap->addr = IOMAP_NULL_ADDR; + iomap->type = IOMAP_INLINE; + } else if (em->disk_bytenr == EXTENT_MAP_HOLE || + (!write && (em->flags & EXTENT_FLAG_PREALLOC))) { + iomap->addr = IOMAP_NULL_ADDR; + iomap->type = IOMAP_HOLE; + } else if (extent_map_is_compressed(em)) { + iomap->type = IOMAP_ENCODED; + iomap->addr = em->disk_bytenr; + } else { + iomap->addr = extent_map_block_start(em); + iomap->type = IOMAP_MAPPED; + } + iomap->offset = em->start; + iomap->bdev = fs_info->fs_devices->latest_dev->bdev; + iomap->length = em->len; +} + static struct extent_map *__get_extent_map(struct inode *inode, struct folio *folio, u64 start, u64 len, struct extent_map **em_cached) From patchwork Fri Oct 4 20:04:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822953 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 608C01DF72C; Fri, 4 Oct 2024 20:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072346; cv=none; b=Mm1EKXmjrxrPO5Gc3rgA4PoSMQZu3sPcE+sih7D5ICVXNEzR/AzKjt+pht3/fkFUExBHyCDfkTc9BuA0NdZZ3jYVMrMFv4DFBFbxpiXHkwrqzUiirwt4pqnZaJeLlJIpHOLr+j3xOa15gXzl76m4GPGX7TsggDwIuNoI553Lbqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072346; c=relaxed/simple; bh=Adkfi/1bKk2ccBTcF21BVys24OgiR1VQ0O/MOOVPcCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fro5oaKUCIZNzbmEGUIcRMXf89TSrhW7wzM9bnYjNOAZWYfiWRYQ+eRPjXr+U7YrqlQJcZ1LWc8oiro3Gpflpk3lXXBJyUBetsh7AaruPhHPFpaSW8O9+Me9rs7IitoHteyJcMLKlhbS/uHGgQGletw65xojU+urO/63Mg9XXm8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=bnX0pcnE; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=FuRQmcj+; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=bnX0pcnE; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=FuRQmcj+; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bnX0pcnE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="FuRQmcj+"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bnX0pcnE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="FuRQmcj+" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A80AB21D52; Fri, 4 Oct 2024 20:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072342; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H0V4CHAX3CWflF16IyoE2yVn73SneAgekRD+IOv9G1c=; b=bnX0pcnE8WvSdo0M9gkfit09YDIUsona76UYRnEvs7wsel27J4OmgcVAuXE8t6gpzWVeFB 4jbj2vMqI1XsELpKnJVZvYiRh7pz5FCgDBypiiMytvprX6GmYgO+QeizxoKRImJm/vqqEV XUF4RTcOZN+GI0SNxVgAci8gOx4vUMY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072342; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H0V4CHAX3CWflF16IyoE2yVn73SneAgekRD+IOv9G1c=; b=FuRQmcj+ACxzOgLuNERjZcSj7QBBxJAGtd+9DTUxGhKxw3Rv4uFo2WUoeVja4QS7t9hrep 8G1+ApQNdHMn7ECQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=bnX0pcnE; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=FuRQmcj+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072342; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H0V4CHAX3CWflF16IyoE2yVn73SneAgekRD+IOv9G1c=; b=bnX0pcnE8WvSdo0M9gkfit09YDIUsona76UYRnEvs7wsel27J4OmgcVAuXE8t6gpzWVeFB 4jbj2vMqI1XsELpKnJVZvYiRh7pz5FCgDBypiiMytvprX6GmYgO+QeizxoKRImJm/vqqEV XUF4RTcOZN+GI0SNxVgAci8gOx4vUMY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072342; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H0V4CHAX3CWflF16IyoE2yVn73SneAgekRD+IOv9G1c=; b=FuRQmcj+ACxzOgLuNERjZcSj7QBBxJAGtd+9DTUxGhKxw3Rv4uFo2WUoeVja4QS7t9hrep 8G1+ApQNdHMn7ECQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3E08713883; Fri, 4 Oct 2024 20:05:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IgnlApZKAGcTRgAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:42 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 08/12] btrfs: iomap_begin() for buffered reads Date: Fri, 4 Oct 2024 16:04:35 -0400 Message-ID: <5cba21c0cbc0da7adaa186f0163939912edd61d9.1728071257.git.rgoldwyn@suse.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: A80AB21D52 X-Spam-Level: X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid,suse.de:dkim]; FROM_EQ_ENVFROM(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.01 X-Spam-Flag: NO From: Goldwyn Rodrigues btrfs_read_iomap_begin() fetches the extent on the file position passed and converts the resultant extent map to iomap. The iomap code uses the sector offset from iomap structure to create the bios. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/extent_io.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 7f40c2b8bfb8..6ef2fa802c30 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -962,6 +962,34 @@ static struct extent_map *__get_extent_map(struct inode *inode, return em; } + +static int btrfs_read_iomap_begin(struct inode *inode, loff_t pos, + loff_t length, unsigned int flags, struct iomap *iomap, + struct iomap *srcmap) +{ + struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); + struct extent_map *em; + struct extent_state *cached_state = NULL; + u64 start = round_down(pos, fs_info->sectorsize); + u64 end = round_up(pos + length, fs_info->sectorsize) - 1; + + btrfs_lock_and_flush_ordered_range(BTRFS_I(inode), start, end, &cached_state); + em = btrfs_get_extent(BTRFS_I(inode), NULL, start, end - start + 1); + unlock_extent(&BTRFS_I(inode)->io_tree, start, end, &cached_state); + if (IS_ERR(em)) + return PTR_ERR(em); + + btrfs_em_to_iomap(inode, em, iomap, start, false); + free_extent_map(em); + + return 0; +} + +static const struct iomap_ops btrfs_buffered_read_iomap_ops = { + .iomap_begin = btrfs_read_iomap_begin, +}; + + /* * basic readpage implementation. Locked extent state structs are inserted * into the tree that are removed when the IO is done (by the end_io From patchwork Fri Oct 4 20:04:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822954 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C93C1E47D0; Fri, 4 Oct 2024 20:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072348; cv=none; b=L8vdVWN+7xyXxnkZhSUh9+yTEL0vQG6Jx3vVHnY7rjbNwJ8mpWxEnAmaxF8pDPwf8tF46H4HU/eQL2g+8N5SyunmTDPi8TAUdqRlSv3F6rTZ/A14ScX5MQ5/26vMLpwysA/Wh575X3fvTZ83Nu2rC+9sMg8YzLZ8E6h+7X5FpLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072348; c=relaxed/simple; bh=PuD/I5QXqYP/O4WImRLYF56eQyQMPoPQIYm7NEd+g1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sWHIHspX2h+TqgBRfiL7nEsQ6Mh8kgXoLh0Nl+HazkD8oyt/0MFMGEdCFTQPiZpKsGIX/4Xfqpr1r/CCM+6BXxuxeYYR8eVkQQ5VhpaeDWpj+UpymbC/L65Dj+wuXWix/v20wp8q8WxXkMG9+o8um2b0BYeR0ryZDgunwH8nchc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=BJXp+8GE; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=jQ1NImr3; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=BJXp+8GE; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=jQ1NImr3; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="BJXp+8GE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="jQ1NImr3"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="BJXp+8GE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="jQ1NImr3" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 87D801F7B4; Fri, 4 Oct 2024 20:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072345; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BN85Mr+H2PhAw1Iz0PjMb3XgLjDwYMp6X1VHr0q1Bds=; b=BJXp+8GEPFNTDEdYur3EAm2QxT3sALsWI7l5T/TrvQd0oPT+TyQ4lCGNvaRmDmJtZ28sF+ Qjd5Ixlouo+S6/+g6BTvsmbh/7g0jaj8YMZ1N+3ALJErZ7BCbSlRB5h8y6mtb2SyEim1Oq XRKPr93bGNXCu+oHOipfn5w/AgbaDhs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072345; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BN85Mr+H2PhAw1Iz0PjMb3XgLjDwYMp6X1VHr0q1Bds=; b=jQ1NImr3LtK8L7T9jiE9aG2pWHbgkqE9uluHP/VCL6DtnLj2RSPPutT57PnkgDI+pmTceB oSNlN/gHikR2j2BA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072345; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BN85Mr+H2PhAw1Iz0PjMb3XgLjDwYMp6X1VHr0q1Bds=; b=BJXp+8GEPFNTDEdYur3EAm2QxT3sALsWI7l5T/TrvQd0oPT+TyQ4lCGNvaRmDmJtZ28sF+ Qjd5Ixlouo+S6/+g6BTvsmbh/7g0jaj8YMZ1N+3ALJErZ7BCbSlRB5h8y6mtb2SyEim1Oq XRKPr93bGNXCu+oHOipfn5w/AgbaDhs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072345; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BN85Mr+H2PhAw1Iz0PjMb3XgLjDwYMp6X1VHr0q1Bds=; b=jQ1NImr3LtK8L7T9jiE9aG2pWHbgkqE9uluHP/VCL6DtnLj2RSPPutT57PnkgDI+pmTceB oSNlN/gHikR2j2BA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1EC3113883; Fri, 4 Oct 2024 20:05:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id FsSLNphKAGcYRgAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:44 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 09/12] btrfs: define btrfs_iomap_read_folio_ops Date: Fri, 4 Oct 2024 16:04:36 -0400 Message-ID: <3b91f2eb82e9b6614732dc2df03c41c63dfc0a12.1728071257.git.rgoldwyn@suse.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Score: -3.80 X-Spamd-Result: default: False [-3.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Level: From: Goldwyn Rodrigues Use btrfs_bioset so iomap allocates btrfs_bio for bios to be submitted for btrfs. Set the file_offset of the bbio from the first folio in the bio. For compressed/encoded reads, call btrfs_submit_compressed_read() else call btrfs_submit_bbio() After the read is complete, call iomap_read_end_io() to finish reads on the folios. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/bio.c | 2 +- fs/btrfs/bio.h | 1 + fs/btrfs/extent_io.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index 056f8a171bba..9d448235b8bd 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -15,7 +15,7 @@ #include "file-item.h" #include "raid-stripe-tree.h" -static struct bio_set btrfs_bioset; +struct bio_set btrfs_bioset; static struct bio_set btrfs_clone_bioset; static struct bio_set btrfs_repair_bioset; static mempool_t btrfs_failed_bio_pool; diff --git a/fs/btrfs/bio.h b/fs/btrfs/bio.h index e48612340745..687a8361202a 100644 --- a/fs/btrfs/bio.h +++ b/fs/btrfs/bio.h @@ -15,6 +15,7 @@ struct btrfs_bio; struct btrfs_fs_info; struct btrfs_inode; +extern struct bio_set btrfs_bioset; #define BTRFS_BIO_INLINE_CSUM_SIZE 64 diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 6ef2fa802c30..43418b6d4824 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -985,10 +985,39 @@ static int btrfs_read_iomap_begin(struct inode *inode, loff_t pos, return 0; } +static void btrfs_read_endio(struct btrfs_bio *bbio) +{ + iomap_read_end_io(&bbio->bio); +} + +static void btrfs_read_submit_io(struct inode *inode, struct bio *bio, + const struct iomap *iomap) +{ + struct btrfs_bio *bbio = btrfs_bio(bio); + struct folio_iter fi; + + btrfs_bio_init(bbio, btrfs_sb(inode->i_sb), btrfs_read_endio, NULL); + bbio->inode = BTRFS_I(inode); + + bio_first_folio(&fi, bio, 0); + bbio->file_offset = folio_pos(fi.folio); + + if (iomap->type & IOMAP_ENCODED) { + bbio->bio.bi_iter.bi_sector = iomap->addr >> SECTOR_SHIFT; + btrfs_submit_compressed_read(bbio); + } else { + btrfs_submit_bbio(bbio, 0); + } +} + static const struct iomap_ops btrfs_buffered_read_iomap_ops = { .iomap_begin = btrfs_read_iomap_begin, }; +static const struct iomap_read_folio_ops btrfs_iomap_read_folio_ops = { + .submit_io = btrfs_read_submit_io, + .bio_set = &btrfs_bioset, +}; /* * basic readpage implementation. Locked extent state structs are inserted From patchwork Fri Oct 4 20:04:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822955 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 372911E570E; Fri, 4 Oct 2024 20:05:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072351; cv=none; b=LUdFmX7Q1zqIqrt15dWKSCwWNhRuHxgxeij9A1S05Z9mJY+k9Tmlc1bqNUwgLEZak8js5L4drIr/EAG+xUleD5mXXi9JptSlq305xsIU4JnWFQQBHFX8in2ZphAPOAV+Q5qw/zdkE4a8EcR2h+zbpnR9wxCQVpuONdtBAqq156U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072351; c=relaxed/simple; bh=yfGJjnBSUPGrHM1dD5nGyR1mtPukB3paH1VRSRCcrUM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NOzxWLGPigB83h/1ddO/jiyfMdzOefoyNuvwEaCiH8ERTABUjCRRb8XrFpixve5tpuXK4dmQ+iGO3+OwS8tHVgit/ByHa8cihgu5S2Dqtik1GZpQw5aJeY0ZSLLfPSuysmspod+0SQ0dW7+YciBu82DV29v6rhhEfN0o21nmL/w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=kHV6nNBC; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=8bODU4BO; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=kHV6nNBC; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=8bODU4BO; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kHV6nNBC"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="8bODU4BO"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kHV6nNBC"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="8bODU4BO" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 76B0721D52; Fri, 4 Oct 2024 20:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072348; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OtZfPO1TX+6o6miSxN7nepDGS71ntxoJ0o0onBRQM6o=; b=kHV6nNBC6UjmyEp1Vd2HeWiT8gdRTpioxaBRqRfNG5yYG64VtroUOUzpJcR5eNbDtYwpc0 FgEvzAWhGcCeF+GdiPxaK+HZf40CT0EAtg585+tr9tfOudVqaQRQuf75pMbLn6EePPxVYH mWBkJI8gKK+XpXBK3jdc9Ls4qXST4Po= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072348; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OtZfPO1TX+6o6miSxN7nepDGS71ntxoJ0o0onBRQM6o=; b=8bODU4BO6xTKeiYe8R7VUHkxDGU0LHWTa25fhvd57+wXb0/hX8zi0VwVud3FwoIAGKHNr8 7CY6pt3UszZq7LBw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=kHV6nNBC; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=8bODU4BO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072348; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OtZfPO1TX+6o6miSxN7nepDGS71ntxoJ0o0onBRQM6o=; b=kHV6nNBC6UjmyEp1Vd2HeWiT8gdRTpioxaBRqRfNG5yYG64VtroUOUzpJcR5eNbDtYwpc0 FgEvzAWhGcCeF+GdiPxaK+HZf40CT0EAtg585+tr9tfOudVqaQRQuf75pMbLn6EePPxVYH mWBkJI8gKK+XpXBK3jdc9Ls4qXST4Po= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072348; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OtZfPO1TX+6o6miSxN7nepDGS71ntxoJ0o0onBRQM6o=; b=8bODU4BO6xTKeiYe8R7VUHkxDGU0LHWTa25fhvd57+wXb0/hX8zi0VwVud3FwoIAGKHNr8 7CY6pt3UszZq7LBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1566313883; Fri, 4 Oct 2024 20:05:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Kb23NJtKAGceRgAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:47 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 10/12] btrfs: define btrfs_iomap_folio_ops Date: Fri, 4 Oct 2024 16:04:37 -0400 Message-ID: <3ff1d03f6be91450830060372337b27c0a600d38.1728071257.git.rgoldwyn@suse.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 76B0721D52 X-Spam-Level: X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid,suse.de:dkim]; FROM_EQ_ENVFROM(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.01 X-Spam-Flag: NO From: Goldwyn Rodrigues The put_folio() sets folio->private to EXTENT_PAGE_PRIVATE if not already set using set_page_extent_mapped(). Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/extent_io.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 43418b6d4824..ee0d37388441 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -901,6 +901,18 @@ void clear_folio_extent_mapped(struct folio *folio) folio_detach_private(folio); } +static void btrfs_put_folio(struct inode *inode, loff_t pos, + unsigned copied, struct folio *folio) +{ + set_folio_extent_mapped(folio); + folio_unlock(folio); + folio_put(folio); +} + +static const struct iomap_folio_ops btrfs_iomap_folio_ops = { + .put_folio = btrfs_put_folio, +}; + static void btrfs_em_to_iomap(struct inode *inode, struct extent_map *em, struct iomap *iomap, loff_t sector_pos, bool write) @@ -928,6 +940,7 @@ static void btrfs_em_to_iomap(struct inode *inode, iomap->offset = em->start; iomap->bdev = fs_info->fs_devices->latest_dev->bdev; iomap->length = em->len; + iomap->folio_ops = &btrfs_iomap_folio_ops; } static struct extent_map *__get_extent_map(struct inode *inode, From patchwork Fri Oct 4 20:04:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822956 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A648A1E572D; Fri, 4 Oct 2024 20:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072355; cv=none; b=sPyXFAx2Aa0zNMBeLpIh4KsdNWR4D4vhTo7sQopJam6FwS8vmBKlflFMe8rIM0H8jOq7P0wgBis8d1WfFjjfeX7MPhPAAppvy2Q8r8niE8U9pjivrmkXh89YtHrT12q8AZtjGLfVuJMHKwtb+KsVGCXfXQrMVNdAXH5vudaIKZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072355; c=relaxed/simple; bh=ziEcWdyrEd3AJEAja2+Tdj/EPxHT8uE15hsZbtn3Pxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C3DbzIF4ybO6TKhXZS5C1Z7QadvTsSL2Chfxgpk6biYyQECbT6nRiJ+OtpNn46Z8oExyVZK4Tsoyby3YeEuraf30zKDJl46tCBtlSH9ErEHD3Rkymec2cFKS0KGs5j89pF32q45N/jTG7PCfS9SMOi37IwKq33soP8H9v2HU+5c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=g0Z7/b0y; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=5Ty92CDL; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=g0Z7/b0y; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=5Ty92CDL; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="g0Z7/b0y"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="5Ty92CDL"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="g0Z7/b0y"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="5Ty92CDL" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 01DE321D52; Fri, 4 Oct 2024 20:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072352; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VAdg/Dy5/k3zGiStjJba9gGroujDlcopd/g/2dyWjeo=; b=g0Z7/b0yipL2GJg7vA5MzCxf+kSNDfb/RjN/3koM3no+IXFhX/tuluzj3GEyslwfn69BTC HLZ0iwLsZlIxMedKOAq51fbZVj+88bEGZiNm5H06NJE3IG4X9ihFf2glNjHD2cto6nE/im udprZluijGq0KQTmpB/Dr0bEpTOgcOY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072352; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VAdg/Dy5/k3zGiStjJba9gGroujDlcopd/g/2dyWjeo=; b=5Ty92CDLpMEISrRnFu+m+HkKR0MRK3mxCu5voYI7leCPH14u3EnEJouOLnexpj4DgG7+aq 9S+srC1Y8Amv6BDA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072352; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VAdg/Dy5/k3zGiStjJba9gGroujDlcopd/g/2dyWjeo=; b=g0Z7/b0yipL2GJg7vA5MzCxf+kSNDfb/RjN/3koM3no+IXFhX/tuluzj3GEyslwfn69BTC HLZ0iwLsZlIxMedKOAq51fbZVj+88bEGZiNm5H06NJE3IG4X9ihFf2glNjHD2cto6nE/im udprZluijGq0KQTmpB/Dr0bEpTOgcOY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072352; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VAdg/Dy5/k3zGiStjJba9gGroujDlcopd/g/2dyWjeo=; b=5Ty92CDLpMEISrRnFu+m+HkKR0MRK3mxCu5voYI7leCPH14u3EnEJouOLnexpj4DgG7+aq 9S+srC1Y8Amv6BDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8B44713883; Fri, 4 Oct 2024 20:05:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id NLnYFZ9KAGcjRgAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:51 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 11/12] btrfs: add read_inline for folio operations for read() calls Date: Fri, 4 Oct 2024 16:04:38 -0400 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-3.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -3.80 X-Spam-Flag: NO From: Goldwyn Rodrigues Use the iomap read_inline() hook to fill data into the folio passed. Just call btrfs_get_extent() again, because this time read_inline() function has the folio present. Comment: Another way to do this is to bounce around btrfs_path all the way to read_inline() function. This was getting too complicated with cleanup, but should reduce the number of operations to fetch an inline extent. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/extent_io.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index ee0d37388441..01408bc5b04e 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -909,8 +909,26 @@ static void btrfs_put_folio(struct inode *inode, loff_t pos, folio_put(folio); } +static int btrfs_iomap_read_inline(const struct iomap *iomap, struct folio *folio) +{ + int ret = 0; + struct inode *inode = folio->mapping->host; + struct extent_map *em; + struct extent_state *cached_state = NULL; + + lock_extent(&BTRFS_I(inode)->io_tree, 0, folio_size(folio) - 1, &cached_state); + em = btrfs_get_extent(BTRFS_I(inode), folio, 0, folio_size(folio)); + unlock_extent(&BTRFS_I(inode)->io_tree, 0, folio_size(folio) - 1, &cached_state); + if (IS_ERR(em)) + ret = PTR_ERR(em); + free_extent_map(em); + return ret; +} + + static const struct iomap_folio_ops btrfs_iomap_folio_ops = { .put_folio = btrfs_put_folio, + .read_inline = btrfs_iomap_read_inline, }; static void btrfs_em_to_iomap(struct inode *inode, From patchwork Fri Oct 4 20:04:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13822957 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 924DF1E5738; Fri, 4 Oct 2024 20:05:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072358; cv=none; b=Yyb1P0B7E80uvnNNdhdziUVMbK3qGgsSkXW3Xa4VSSDM/cuyaXjWB1a7r1aRI+Fax2StIXvJzh0p2d9WYo8s7Q/Y0Y6g99hvMvcjS3Ls9KeFMqETao0l636S0d58YNlHrciQMXckpedGCRxii57cj3AhxaL0kBjd1uEoKd37NPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728072358; c=relaxed/simple; bh=jfjst3E5k0T2B6zwqixGj4yYauvR0JGYmKe7AjK0JHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UHUAEKy9ncZWHunb91gmy4L8gV5p03NbuQX3tIXpX4wFKfPlufm+/DPhDx1GvDQcV8XBxp1MzXM+NpmImm5GPL/dFh2b44GmOiFhOB5zY5W1TyqaOH0AhX1X1g1W8LAFcHNwNJ4mNLtz39F98/HldVQVphwDsk0f00e15I2V9Mo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=CsbIGiaK; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=d7yWeA6z; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=CsbIGiaK; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=d7yWeA6z; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="CsbIGiaK"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="d7yWeA6z"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="CsbIGiaK"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="d7yWeA6z" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D5ADA1F7B4; Fri, 4 Oct 2024 20:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072354; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f4bhyoD+vXWDSv7I9433nLLALeIWNmirY85fvj5iloo=; b=CsbIGiaKDGGN2nqjI53FXD00QOoqin/aPN8c7JdYHSgcHKhOd1+CoHWO5yaIEwSfxHCCh0 TXbld0F7GwBlI0gQNYd7rhTtSu+2uiP9yTaEsdsF3CWxrBw1jsFT4DdralN2eNJq7GQ+ZS 3JcCJD7KXXqOdNWNDyMvsyh9QY/2LOo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072354; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f4bhyoD+vXWDSv7I9433nLLALeIWNmirY85fvj5iloo=; b=d7yWeA6zvalmhHwcTTgWyG1nkkXiJVhJOZeyVXS/vymXeJpZ0HhzSBSnKcgNOILL5DuBog hLSZX88KUFWQt3BQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728072354; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f4bhyoD+vXWDSv7I9433nLLALeIWNmirY85fvj5iloo=; b=CsbIGiaKDGGN2nqjI53FXD00QOoqin/aPN8c7JdYHSgcHKhOd1+CoHWO5yaIEwSfxHCCh0 TXbld0F7GwBlI0gQNYd7rhTtSu+2uiP9yTaEsdsF3CWxrBw1jsFT4DdralN2eNJq7GQ+ZS 3JcCJD7KXXqOdNWNDyMvsyh9QY/2LOo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728072354; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f4bhyoD+vXWDSv7I9433nLLALeIWNmirY85fvj5iloo=; b=d7yWeA6zvalmhHwcTTgWyG1nkkXiJVhJOZeyVXS/vymXeJpZ0HhzSBSnKcgNOILL5DuBog hLSZX88KUFWQt3BQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6AF5F13883; Fri, 4 Oct 2024 20:05:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id dzjgDaJKAGcqRgAAD6G6ig (envelope-from ); Fri, 04 Oct 2024 20:05:54 +0000 From: Goldwyn Rodrigues To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 12/12] btrfs: switch to iomap for buffered reads Date: Fri, 4 Oct 2024 16:04:39 -0400 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-3.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -3.80 X-Spam-Flag: NO From: Goldwyn Rodrigues For buffered reads, call iomap_readahead() and iomap_read_folio(). This is limited to non-subpage calls. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/extent_io.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 01408bc5b04e..cfe771cebb36 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1205,9 +1205,15 @@ static int btrfs_do_readpage(struct folio *folio, struct extent_map **em_cached, int btrfs_read_folio(struct file *file, struct folio *folio) { struct btrfs_bio_ctrl bio_ctrl = { .opf = REQ_OP_READ }; + struct inode *inode = folio->mapping->host; + struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct extent_map *em_cached = NULL; int ret; + if (!btrfs_is_subpage(fs_info, inode->i_mapping)) + return iomap_read_folio(folio, &btrfs_buffered_read_iomap_ops, + &btrfs_iomap_read_folio_ops); + ret = btrfs_do_readpage(folio, &em_cached, &bio_ctrl, NULL); free_extent_map(em_cached); @@ -2449,10 +2455,17 @@ int btrfs_writepages(struct address_space *mapping, struct writeback_control *wb void btrfs_readahead(struct readahead_control *rac) { struct btrfs_bio_ctrl bio_ctrl = { .opf = REQ_OP_READ | REQ_RAHEAD }; + struct inode *inode = rac->mapping->host; + struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct folio *folio; struct extent_map *em_cached = NULL; u64 prev_em_start = (u64)-1; + if (!btrfs_is_subpage(fs_info, rac->mapping)) { + iomap_readahead(rac, &btrfs_buffered_read_iomap_ops, &btrfs_iomap_read_folio_ops); + return; + } + while ((folio = readahead_folio(rac)) != NULL) btrfs_do_readpage(folio, &em_cached, &bio_ctrl, &prev_em_start);