Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp976532lqd; Thu, 25 Apr 2024 02:19:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUvCQNUJB6R0l6xnjsxI55VzmvHw347gqtu+X0lEd+qp8lV7Y0IsBu1riZTribITOQUnKXQMLM/WPrQ6cmmERQmKDsxM3hKQ8NWtb1tZA== X-Google-Smtp-Source: AGHT+IGgxUi2F8NkeQVuQReEHVGOcD1MhCrDlgQIo2IEmP+jLyLQpXOvXPP5jqfOd0zsR3+ivDoI X-Received: by 2002:a17:902:f64e:b0:1e4:3f6d:20f6 with SMTP id m14-20020a170902f64e00b001e43f6d20f6mr7258412plg.30.1714036799147; Thu, 25 Apr 2024 02:19:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714036799; cv=pass; d=google.com; s=arc-20160816; b=N0QfI4lDSI9B+pINVARRqcZ1uN7T1XNTNn4+mTa8iunFVgVtFiK0OlAW2adOJHh5Av vmvHefExynQXpxU9UKEy36iCo61EdCClMvTSd71+zJdZ2VUk7PcBABQJTGRzAsl9iOd0 UJYmTEVceCBV6bH5A2kXdLjWy3b1EZNu0yXoA5fy3R34m3yeWe8NmcCFObYxRmzJGOQJ ui4rNIMhBNLeTmUWCFjMd7yCJo+hUDI/cWi7eK3tCWK30w0lwmG5fr3bmDAg84xyzrby 4//J/L7YgrJ+aMJRJfeC7d0EFgyjgMscFNwiC3foVOQgZPGZKRE5ieHgN+8eZck9cI/P k3VQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=w9QN+P4vB8I0CAC9KqWe0wqLc0QQQLpQU5nSVu5xq8Q=; fh=uRRo/bsVkkMz4T1a2t0y0xSNbzWg22XBPvnHoLuz/8k=; b=n2n2p0fR26HqTkDQycuUL+rklY0bFj58Ad0QNAMzA2s2cz7CsEgSj0a7hFleeqUwzl F92da8vNn3rw67Z9uvrH9W4EKlAyWxDeHFyDPp2pC5tkDBTkcfhjbuJZUz1JCtH4p1uz Dm0u8oJ67tVtQL7PBP0DoMXe50qb6TVwZZoB3U5kvN16S1IPEOebOkQgmUFq9F/hL8XJ IVpuqOJxuGn8lSmz2uvqPAEg+bMSitTk9GKHmIs/MsA8Ei3xctoDVRBc7nRZ8e9aTDUW iInbh0tyq60JyHZfI8Ff5wmzfIq6H/WNSaYY9X/NnJ228Im4A+OzZ1OEwIpOhYveeLt0 6nOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=HQBOLnHA; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-158268-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158268-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k15-20020a170902ce0f00b001e4b20c22b9si13106225plg.101.2024.04.25.02.19.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 02:19:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158268-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=HQBOLnHA; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-158268-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158268-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2A98828497B for ; Thu, 25 Apr 2024 09:19:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4564C1272AA; Thu, 25 Apr 2024 09:17:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="HQBOLnHA" Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 214E5128361 for ; Thu, 25 Apr 2024 09:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714036666; cv=none; b=lxoKhuyA3BP6Mte4fj4RAoXzkVkwgrkxcnts5jiHalc1q0J+5CTtMn4w8x3c5XSJbQhmPrd2RBh6UyO/UJysI58mojYESV7zvyMSNxKS66Vmc0dd68FzK9p6TPMqCD6WtjYUCceL8iYrqK/wjvZX7Am8vEL7PXyT2eEKiIIPEt8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714036666; c=relaxed/simple; bh=65YKvGP5ldFEl9ghgHolAKwSIFb4oPQzeVo0l5Pgbv4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=S3lOiyplDuKnpewiV6TcJnEIU/2AAMzLErSYpTX0UscAnCKZJI1BytzYE0uUZgd631Ng1SmmaMk1a7igiFfhRbaY9qDb1I5fCwczmI1Om8FXxbNFzW5c0N/6gS92PJSyLBu3amNOqrN1Ug8YVV71XN2Xd6dwfpehVJdXdNAZ2No= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=HQBOLnHA; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714036661; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=w9QN+P4vB8I0CAC9KqWe0wqLc0QQQLpQU5nSVu5xq8Q=; b=HQBOLnHAvyMVhYpOUP0Uy4vb/0VlhxF6hu9ZovWP9+FnnMWH6ZO3dz+BEbGKZdPoUdksWg MvsPvYKnkSYuX60kwCTS2RFbFOPiJYG9INYQrfQsbzEZFcgcJZ8ZhFkV9J/16qhEda74+B rdodoLIv02D7/9owtFkLy+FjIkYsKW0= From: Youling Tang To: Kent Overstreet Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, Youling Tang Subject: [PATCH] bcachefs: Use filemap_read() to simplify the execution flow Date: Thu, 25 Apr 2024 17:16:59 +0800 Message-Id: <20240425091659.6148-1-youling.tang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Youling Tang Using filemap_read() can reduce unnecessary code execution for non IOCB_DIRECT paths. Signed-off-by: Youling Tang --- fs/bcachefs/fs-io-direct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/fs-io-direct.c b/fs/bcachefs/fs-io-direct.c index 09d21aef879a..4072a6ba0d51 100644 --- a/fs/bcachefs/fs-io-direct.c +++ b/fs/bcachefs/fs-io-direct.c @@ -179,7 +179,7 @@ ssize_t bch2_read_iter(struct kiocb *iocb, struct iov_iter *iter) struct bch_inode_info *inode = file_bch_inode(file); struct address_space *mapping = file->f_mapping; size_t count = iov_iter_count(iter); - ssize_t ret; + ssize_t ret = 0; if (!count) return 0; /* skip atime */ @@ -205,7 +205,7 @@ ssize_t bch2_read_iter(struct kiocb *iocb, struct iov_iter *iter) iocb->ki_pos += ret; } else { bch2_pagecache_add_get(inode); - ret = generic_file_read_iter(iocb, iter); + ret = filemap_read(iocb, iter, ret); bch2_pagecache_add_put(inode); } out: -- 2.34.1