From patchwork Mon Aug 26 21:19:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13778495 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (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 D4C44881E for ; Mon, 26 Aug 2024 21:20:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707205; cv=none; b=m8PDq86U22ezsHimdBZJNi5rZISqt/2Vjvo1VwLW19g7W4XEgXSQXQySmfZgxshAZO2bsUlbJ1Y1yNtpRcR4gWo47AMGT/ETYcu9iYlb/IGAYRjwrUAweaXUzgWS+SUuZi5RlxCy6X1QP+GT6bEvWljTVQvhUeo2e9duB8F3BVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707205; c=relaxed/simple; bh=d1sw3RklYepjEi8jrs758o0Ste9SePDfyolWUw0Jdxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FMZUfZXQGAPTd7y2AhLt23DcqNd/FRgbzo64d0BkQeOKoZnVECJ+QcOTZssdGdxtkWEV3PuJQCtMg3M7GNwmLNKZUFs3tA3gsWPm4lYuQMvAHQ/7XBFtE6ILwPvYDLVUhZjJr561QXtj936JJxSXsl/FMb6F5fDx2hBU0nu6V3Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a5uAnZld; arc=none smtp.client-ip=209.85.219.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a5uAnZld" Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-e1633202008so4727146276.2 for ; Mon, 26 Aug 2024 14:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724707203; x=1725312003; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=grTnWehlIm/aEMMtVTYddChEg6d1BbxYt+fz0gv8hQY=; b=a5uAnZldFb4U0bUld0PZQZjFudKPHnojFCT4Pnnr4Cpa9CfwX9Q2GCrOfhZhT1Jb1O nvoXKlyc5AbtmsEHNxWkTJeOm0sPjJN82YX8FQK1FuOJTom9OeFu1hDlzOpjefys27Gq QFu6oj6m2TrAI54nR8+ikofgPCk0Pmg6og9xRG0XQpUYqjOK8N5MDp90sbjDcNhH+gIS L9nTR0QPLUd6gjKfL27AAbinRS/bdtiGHJ/gvpNhlblst49JSC/Png8mQhDZztIn02kh rTvEWsTRBh1P2q4mbGp3Y96j6xq6ClHDFZye+H2u8yD0XuMzRmtN9Vti8FydfdsPLNLd F1gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724707203; x=1725312003; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=grTnWehlIm/aEMMtVTYddChEg6d1BbxYt+fz0gv8hQY=; b=siiiym/A5KTyclrgCAI2hNEpKF/d9AAqFDPwZoGDIhM1Q2Yo3Ucvmodco4nv9I6As2 DYDI29ST1JqVyXu7hCZIff8tDuOJE6UFUj1a0X4vZzvZkIwZI+Bx4CYiPiqA+n4/jjlw ZHD0rPIHwyCjLDct/Uc880S+AG6i4dbAE9KQwz3VrIU4Dj8pA7BnTLz5XqKFzoIZZO+e sDVm1qZXZfSUCq8BaMOlantDwvx41sKYEDlj8JBhL0ml2wPvhQkvuwyk/OcsTd1YnA9u M0klc9JgFGN9yXqGUBBdLLrWDlersdZpzl91hOdZsHIFcu+YS6n8NoFhJfrXtQANcKgg sALQ== X-Forwarded-Encrypted: i=1; AJvYcCWcFCJmJYAb4WA8xeRVCsHLXnf103EdcZu+qgeEgOGoHjBk08PisSwS+F0cFMSF37D1ELb2TCpdRLfzzEF5@vger.kernel.org X-Gm-Message-State: AOJu0Yyfa6snRO5fjV0d5gHHqiPdmNChqhxs8Ga+K5qBeL+858Qxs6En BCj60u+4B9HNfH4xQ4+Sbea4chspGClYOZ8Y2dbJ6L46sAllvp0s X-Google-Smtp-Source: AGHT+IETDX8+GE+Kwr0asbT4H3r3OxV1hmmp7+osRDVF3LTxazxEZzjHT6ReLXdInHEVRA81eYHV2g== X-Received: by 2002:a05:6902:102e:b0:e0e:3ee7:751d with SMTP id 3f1490d57ef6-e1a2a5a6a10mr921048276.11.1724707202790; Mon, 26 Aug 2024 14:20:02 -0700 (PDT) Received: from localhost (fwdproxy-nha-116.fbsv.net. [2a03:2880:25ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e178e43fc98sm2232312276.11.2024.08.26.14.20.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 14:20:02 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, kernel-team@meta.com Subject: [PATCH v4 1/7] fuse: drop unused fuse_mount arg in fuse_writepage_finish() Date: Mon, 26 Aug 2024 14:19:02 -0700 Message-ID: <20240826211908.75190-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240826211908.75190-1-joannelkoong@gmail.com> References: <20240826211908.75190-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Drop the unused "struct fuse_mount *fm" arg in fuse_writepage_finish(). No functional changes added. Signed-off-by: Joanne Koong Reviewed-by: Jingbo Xu --- fs/fuse/file.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index f39456c65ed7..63fd5fc6872e 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1769,8 +1769,7 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa) kfree(wpa); } -static void fuse_writepage_finish(struct fuse_mount *fm, - struct fuse_writepage_args *wpa) +static void fuse_writepage_finish(struct fuse_writepage_args *wpa) { struct fuse_args_pages *ap = &wpa->ia.ap; struct inode *inode = wpa->inode; @@ -1829,7 +1828,7 @@ __acquires(fi->lock) out_free: fi->writectr--; rb_erase(&wpa->writepages_entry, &fi->writepages); - fuse_writepage_finish(fm, wpa); + fuse_writepage_finish(wpa); spin_unlock(&fi->lock); /* After fuse_writepage_finish() aux request list is private */ @@ -1959,7 +1958,7 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args, fuse_send_writepage(fm, next, inarg->offset + inarg->size); } fi->writectr--; - fuse_writepage_finish(fm, wpa); + fuse_writepage_finish(wpa); spin_unlock(&fi->lock); fuse_writepage_free(wpa); } From patchwork Mon Aug 26 21:19:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13778496 Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) (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 4415A1991C6 for ; Mon, 26 Aug 2024 21:20:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707206; cv=none; b=eiumwduBiJ9FL0Z57BTcHWj/dK8ptKs7V0j85n7ssxxWXOliKNiHPsyhFswWRG4HacgJ+Bwz874FEQTaP7PNvuKvy9nq1Bz92sM+Sr0ZB1RV8/OEmX0p/SyssXcKa/yewuB/pFMhiIXzp0eQvuR4LS4D4afeoEROQinRkWPgqzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707206; c=relaxed/simple; bh=UWKsRqn8KEexlFybvj1D8QiH7e2TeVsMe7AUmeAODaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Db746ilimZiynqEv7HDa4sty9tj1mHMuS9gbAIiuH8iy7gCAHDFItoWHj9JqQDwQeYhyvv+UWwsbJRoUkk/UD2+d1sLpcsLVef5vqDFRo94S+OgQ8RPEAICdw0474Qz6HXKnGDSVhXSi8tLurp0UMwQ4Sp3mkNBIJ7tVAj8YdTM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jNyWsufv; arc=none smtp.client-ip=209.85.219.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jNyWsufv" Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e03caab48a2so3693703276.1 for ; Mon, 26 Aug 2024 14:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724707204; x=1725312004; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YOZ2xVfOWbanp17fZvu+t8asvkce+rrQYJ7+TXN5jw8=; b=jNyWsufvqEDUFQwKN+rU7SE/b0fGP96nmxVQ7NsxHUi0gXUknmc6hvioyHNVRBAGb0 Y1f75Ydk+JZnJ1M8eAYKM7uurqY3ty5lLKGWqQXcrMssBK0pxII+Tin6x5zuquCPwQCH iThfNg4bbNiogLbBXglnikYGU7opwVVjdRJQQfiMWU9afBafE7zZtS0WhQr7kZupOnAc 2150BdhHUjkiRuMPg8fxIcNzGPkm7ee9o4/CpB1z0/J444ick/VSDULpCnVIu0LadfMe WBTgfAAwYyu4Ad/Dmul4E1uLor9Bxu6b6ioe+QHKAID7JlhZXlXDHvEsbheun1StHfEl iPCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724707204; x=1725312004; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YOZ2xVfOWbanp17fZvu+t8asvkce+rrQYJ7+TXN5jw8=; b=vF/20Ge99JW4ATOStCJGqJsaWSBLAL+AdDUtrNBqyJkZTQH9oXWgQ9M+Xk9EjVH8QS 6jn+slWmDjFvkh7HIt0hlZGuHut4DxbyGEja6OhTnaQoWVUvMC8z2GQGRWP5S7gOncoO TInxCLR0iwhTCKqEQDpIjGI/VZ3e9XXNQxcTEbdoLHtTWPURgkj6a90kk4C9vEOhN29S 3X0JNqCpndfULBnZQTqFmEcnVIQz4AIQ2XPbvhQ3sv6Q8bpEl9lPtlIV1SYmerM0Vj+k m7wJMFmjLFcISNZjpAcsdY3hDZW8cu3yKAz9tXcEQf1aQUXJfSwus22HCtE+lWVXgAtl rpoQ== X-Forwarded-Encrypted: i=1; AJvYcCWZyACgBoEajjCQZd+lkdXo+PrncIO6BVvvNs2JYCQf7GRk0id0MImTvtXdacrjhNgkerl3hVun+7sTL5zk@vger.kernel.org X-Gm-Message-State: AOJu0Yybz0E8HPff9yxyjgBDpRXuHWWt+cVrjBjrW3SHYy7erhavMsx1 dpwC+bw+1MYFCqBq5eTsSBqE7JUDEYTrXdciRl6U1D9geCDW/yKe X-Google-Smtp-Source: AGHT+IHuj2sp6wA6WmhnqpJHbsz4oVFoWHVSsn2F1zVor1aCpmP+bEgCwOFfvRZh5Q4Enwhyq7nYmg== X-Received: by 2002:a05:6902:1689:b0:e05:f632:3ef3 with SMTP id 3f1490d57ef6-e1a2987e615mr917882276.23.1724707204190; Mon, 26 Aug 2024 14:20:04 -0700 (PDT) Received: from localhost (fwdproxy-nha-115.fbsv.net. [2a03:2880:25ff:73::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e178e43fc98sm2232320276.11.2024.08.26.14.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 14:20:03 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, kernel-team@meta.com Subject: [PATCH v4 2/7] fuse: refactor finished writeback stats updates into helper function Date: Mon, 26 Aug 2024 14:19:03 -0700 Message-ID: <20240826211908.75190-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240826211908.75190-1-joannelkoong@gmail.com> References: <20240826211908.75190-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the logic for updating the bdi and page stats for a finished writeback into a separate helper function, where it can be called from both fuse_writepage_finish() and fuse_writepage_add() (in the case where there is already an auxiliary write request for the page). No functional changes added. Signed-off-by: Joanne Koong Suggested by: Jingbo Xu --- fs/fuse/file.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 63fd5fc6872e..320fa26b23e8 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1769,19 +1769,25 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa) kfree(wpa); } +static void fuse_writepage_finish_stat(struct inode *inode, struct page *page) +{ + struct backing_dev_info *bdi = inode_to_bdi(inode); + + dec_wb_stat(&bdi->wb, WB_WRITEBACK); + dec_node_page_state(page, NR_WRITEBACK_TEMP); + wb_writeout_inc(&bdi->wb); +} + static void fuse_writepage_finish(struct fuse_writepage_args *wpa) { struct fuse_args_pages *ap = &wpa->ia.ap; struct inode *inode = wpa->inode; struct fuse_inode *fi = get_fuse_inode(inode); - struct backing_dev_info *bdi = inode_to_bdi(inode); int i; - for (i = 0; i < ap->num_pages; i++) { - dec_wb_stat(&bdi->wb, WB_WRITEBACK); - dec_node_page_state(ap->pages[i], NR_WRITEBACK_TEMP); - wb_writeout_inc(&bdi->wb); - } + for (i = 0; i < ap->num_pages; i++) + fuse_writepage_finish_stat(inode, ap->pages[i]); + wake_up(&fi->page_waitq); } @@ -2203,11 +2209,7 @@ static bool fuse_writepage_add(struct fuse_writepage_args *new_wpa, spin_unlock(&fi->lock); if (tmp) { - struct backing_dev_info *bdi = inode_to_bdi(new_wpa->inode); - - dec_wb_stat(&bdi->wb, WB_WRITEBACK); - dec_node_page_state(new_ap->pages[0], NR_WRITEBACK_TEMP); - wb_writeout_inc(&bdi->wb); + fuse_writepage_finish_stat(new_wpa->inode, new_ap->pages[0]); fuse_writepage_free(new_wpa); } From patchwork Mon Aug 26 21:19:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13778497 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (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 8DA69199FA7 for ; Mon, 26 Aug 2024 21:20:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707208; cv=none; b=Fz6krkNEw6WC7vVwv4dNDNq3A0SKFvTcgqHlRd6mo4Il1ovL0FQaE31PhYgaNXipTVOofq+mLY8j8O+KtXn0p9mGLLGdg1v2C9Az7fbciB2LypkNVAhpZG8SS5IHh4fjuwqJN5zmojiRqQIgT7Ok6hON69/hz35/rA3GWZfp7Iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707208; c=relaxed/simple; bh=eaHwMeJ0CTx8L8hGmD/ZgvwlqQiriDj4xMCy/d865M4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RfxpsjguUI6f9UA+IBcLldRyl/Vuwo17uIlFM2wp5HkS/U5tgJbA2UFFsDobGwgWTqgjHv7mVz1T4r2ENtfFylJqni2JVJbA+uh5CwiJFSQpnkBu2AZzxGxm8Rq70gDNR59CvHNywQEkLkLWzokd6Szi651kHBV3A7vzsGDT+vU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TjEDZ1G+; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TjEDZ1G+" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-690aabe2600so43003497b3.0 for ; Mon, 26 Aug 2024 14:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724707205; x=1725312005; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h+JBESYi38EleyLEk7wLfDndWDrXHxRbRmO5HxAqZX4=; b=TjEDZ1G+wjN9TNu59ZXe0z+qcdmBTEDYMvK9stk8uzzZ23jC8TuNGfS4wBHtIe5l1B iut73T1yeS/ce02VkiBG+PiCQhufvZIDLfMh4utZWJiGnmvWcXJw+yhZRLMvZP7kLG3R xqexTgfPDKqHVrVZQVEkabVD9dWaqILZY9YgRRFJLTeES6hJ6nDBmg7j8SkL00+TM+P4 MIsmLBlHOCumKEsluXQMXD4GLc13H3OzRsMr2ADvsUlImStR2hyODpqVJeIHcj30g9ph SsMOAut4L1OTWYL5D+yjGfZDGM2eyy0eyHtgTirrhuZeU80YZxgRkXHMPxXs+kPxA2Lp Kaew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724707205; x=1725312005; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h+JBESYi38EleyLEk7wLfDndWDrXHxRbRmO5HxAqZX4=; b=JirH1dL7Rzd9buOqM3Kewl/JIgGYE25ekKWhZutag+ETVjE1oRAbYVzWAzUG/wtbt1 0aPWEFTfLDFekZlnKuOjadtZgel1+NwDbE90K0JL8p/xL6CImo35Qs7p2ObD58uv1NH2 19o/dSs1usnP3sWOHpyRuqVausJC3XB6Vz/BPzBFw/ISlRSui7sp9yKjD0U4RSM2yFI3 oaSe2Hbph3eMi9Pvi2GFXdkMRb8jerAObL63v0Wav0EkFXRhxVzimKg7d6oEW8bwAcs7 xwhcY0/40vS0Nn/poTYfMxtPzGVspJHCLhEvNHN4JU40CaQ9d3LrLeMTEjgiZRFVAik2 ypHw== X-Forwarded-Encrypted: i=1; AJvYcCUcvpicAk23OBoDVvuF/Q+01FAmhZwahyR8m6qJ6PjRRKANBVTtt92x38UaaR1MYWZY/u7gfCZ27vPSGTIP@vger.kernel.org X-Gm-Message-State: AOJu0YwAp9YOdK85hhwVSXJa83MwzNE9uvfneKsuWsn8imuAx5DBNIpW 1bIQuH3o9d8r5luwXcalXrjIA6OF7zjXLlzGFQYEUpDznk8uXz4fSCsKKQ== X-Google-Smtp-Source: AGHT+IH9Zkh2fvm95EuP4sI5zsaDGuCCq/9KaTVofYUUsRtIqIMSxtqAElssm0WKlesWj6L8ZzSVNQ== X-Received: by 2002:a05:690c:3484:b0:6b0:beef:2e80 with SMTP id 00721157ae682-6c6251a3e82mr102609777b3.17.1724707205486; Mon, 26 Aug 2024 14:20:05 -0700 (PDT) Received: from localhost (fwdproxy-nha-115.fbsv.net. [2a03:2880:25ff:73::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b006490sm16732717b3.63.2024.08.26.14.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 14:20:05 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, kernel-team@meta.com Subject: [PATCH v4 3/7] fuse: update stats for pages in dropped aux writeback list Date: Mon, 26 Aug 2024 14:19:04 -0700 Message-ID: <20240826211908.75190-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240826211908.75190-1-joannelkoong@gmail.com> References: <20240826211908.75190-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In the case where the aux writeback list is dropped (eg the pages have been truncated or the connection is broken), the stats for its pages and backing device info need to be updated as well. Fixes: e2653bd53a98 ("fuse: fix leaked aux requests") Signed-off-by: Joanne Koong --- fs/fuse/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 320fa26b23e8..1ae58f93884e 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1837,10 +1837,11 @@ __acquires(fi->lock) fuse_writepage_finish(wpa); spin_unlock(&fi->lock); - /* After fuse_writepage_finish() aux request list is private */ + /* After rb_erase() aux request list is private */ for (aux = wpa->next; aux; aux = next) { next = aux->next; aux->next = NULL; + fuse_writepage_finish_stat(aux->inode, aux->ia.ap.pages[0]); fuse_writepage_free(aux); } From patchwork Mon Aug 26 21:19:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13778498 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (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 8C68A19AA58 for ; Mon, 26 Aug 2024 21:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707209; cv=none; b=bkqF3/mI0TKi3DJt9a2OjD22vRsyw0bRCse3n6q1fLJzGzUsjQlzu1c6hpeZz5NQ8Z07MjRhDSC1gzH9wVHfnbIEDcOfLB0EOYvnNCCM0+jWPRNcygLWd90wMSgffwKKdQc4uHtHe3j3MIbGCI1YmJrK118wKqdI0s1vF/kMK4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707209; c=relaxed/simple; bh=MI67R3EFlEteAIneyFvcwUjoT88X/jb216z/arR+gWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bZVsE7949blIxQ9VjoZ76MV4RHCkr+kclCldE/dxMamaXh5bztk6tSGLsVhITv4zdG0z4r5Hu2Bys5bl7IpT6Y9BcvtKbcRuuidmYBHG90xsQklt9TO8dqR9cvT7zwmTwTmhayzribNBLpQFjJFLBuWqa87jxIzRYtQKnDpezGA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Uyg2jQrL; arc=none smtp.client-ip=209.85.128.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Uyg2jQrL" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-6b4412fac76so42780137b3.1 for ; Mon, 26 Aug 2024 14:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724707206; x=1725312006; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U9vnF1Yy0n52GKgZoGqTfLdAbmplD+rdXNElY03loVQ=; b=Uyg2jQrL4c7KG+ZDRD/9PeSsdn2wQrpCfsiDerIgIM+04T+7HYmdm9wSHUfhxuFKU+ zRsDqBAnP2i0ViVuvac5/YUnFU22RQnFIQBhI498xgGYJ4McOaLQvD8UgIi8sW3+w3sW rtnDSwck98IaTS4Cq/pQJ8DSgi1aBQyNnOP5QYBH1QAfX5RI4Ymxld7R3shEE+fJR6Wt XHEEAErIxWW1QuPnyK+jZNopIXVtvE9YxMDs4o9FuVrYWQbGYzHFz1uNp5ZYNz62qIGx Nwl+XKQRgcbbXCfcBimrZV4k/g4116LkE9mKjuK/Dy875nZC4X4rk7LQoPBFqsJ6MgCs 9LQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724707206; x=1725312006; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U9vnF1Yy0n52GKgZoGqTfLdAbmplD+rdXNElY03loVQ=; b=RcPhE89dn3z/6p8bbbSqP76Lz2AvMgVYk/mJkGsmnc9Ejy9quYKDmL6rHM9rS58doQ XeFzKekCH4S0wNZ81AXmNzP/zTZJZt8g6iUfhAAKDRwPG0+OQsDJuD42Dq77cZfLZZTS u7Dm2OrJONHvxofYcflYqOHEeYx3WoeCG/KQsp3alvB7Vwlwwhzz5f94wzERGTESN6Wl D9ef7QHSmxv1xPSiozcl2B4UWYabu7Phf+uEFCEoxAx39lPyMCufCWvCOxTFv+pCfPeM iLpLjQy+1Bdt2KGrvFY41FJRO7/zidgDJKUxUiPDmj0yOGOR1X3UoWid3IVQEPSdvPzZ j0NQ== X-Forwarded-Encrypted: i=1; AJvYcCXV3Zdnm+C/4ieErJNth5XtQTBZJNy0QLtDEgWUGEx5wNBfhCCfcmWMJF+gllsgWgCE/apipkFtKLgb8R2l@vger.kernel.org X-Gm-Message-State: AOJu0YwAhtHxmn/YKm1Rm5xbcpUWOqkFZDIYVsGOweTO1fULqVnZfaJA NqOZhS+GUoBVWD8XfwvzitFAUJwXbPhTzyu/QTiqsSkE9Gst1aTl X-Google-Smtp-Source: AGHT+IEJ4+PPCuMbKBBlj/iLl+4b1colQAO20+w3poqvXpnQzUT9S7/U74fzBYgj6eMUyVlN7C46CA== X-Received: by 2002:a05:690c:380b:b0:6c1:2b6d:1964 with SMTP id 00721157ae682-6c62906557cmr137667497b3.38.1724707206594; Mon, 26 Aug 2024 14:20:06 -0700 (PDT) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b005b4asm16618867b3.62.2024.08.26.14.20.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 14:20:06 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, kernel-team@meta.com Subject: [PATCH v4 4/7] fuse: move initialization of fuse_file to fuse_writepages() instead of in callback Date: Mon, 26 Aug 2024 14:19:05 -0700 Message-ID: <20240826211908.75190-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240826211908.75190-1-joannelkoong@gmail.com> References: <20240826211908.75190-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Prior to this change, data->ff is checked and if not initialized then initialized in the fuse_writepages_fill() callback, which gets called for every dirty page in the address space mapping. This logic is better placed in the main fuse_writepages() caller where data.ff is initialized before walking the dirty pages. No functional changes added. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 1ae58f93884e..c1e938b311fb 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2263,13 +2263,6 @@ static int fuse_writepages_fill(struct folio *folio, struct page *tmp_page; int err; - if (!data->ff) { - err = -EIO; - data->ff = fuse_write_file_get(fi); - if (!data->ff) - goto out_unlock; - } - if (wpa && fuse_writepage_need_send(fc, &folio->page, ap, data)) { fuse_writepages_send(data); data->wpa = NULL; @@ -2348,13 +2341,13 @@ static int fuse_writepages(struct address_space *mapping, struct writeback_control *wbc) { struct inode *inode = mapping->host; + struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_fill_wb_data data; int err; - err = -EIO; if (fuse_is_bad(inode)) - goto out; + return -EIO; if (wbc->sync_mode == WB_SYNC_NONE && fc->num_background >= fc->congestion_threshold) @@ -2362,7 +2355,9 @@ static int fuse_writepages(struct address_space *mapping, data.inode = inode; data.wpa = NULL; - data.ff = NULL; + data.ff = fuse_write_file_get(fi); + if (!data.ff) + return -EIO; err = -ENOMEM; data.orig_pages = kcalloc(fc->max_pages, @@ -2376,11 +2371,10 @@ static int fuse_writepages(struct address_space *mapping, WARN_ON(!data.wpa->ia.ap.num_pages); fuse_writepages_send(&data); } - if (data.ff) - fuse_file_put(data.ff, false); kfree(data.orig_pages); out: + fuse_file_put(data.ff, false); return err; } From patchwork Mon Aug 26 21:19:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13778499 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (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 ABDE719AD87 for ; Mon, 26 Aug 2024 21:20:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707210; cv=none; b=czLwUxYT9k16I1R88YwGMIpLiq+NTiP8kH4aNt+Ic/zHlmJBWugHSaIv/PmWx8BLGyMnqYWrl/QG2JHFphu69HFElwyliFxf4Kdk0eHUWIt7lnbbscJ/A7SXGpTiGbYuRhOnM/V3me0/fBIyM8HS7gylE/lQXNS132Jh7+JtEG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707210; c=relaxed/simple; bh=Yop1j2t9YENRO39cwhwSrymZmTy7TmCt7KsuK4eoc44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S3Dj7T6MhmX1V4+2/G3G5uKhQumXEn0b3aM3kWVfzwpraYIqMkuYRrdE6xUxe7/z5JNnZvacoL8spQ2oyQAoNOJT/gcCADudTEMQP2g55u8EQhjqmL4rtmJIX73G/9L/AkOBlHCoT7w6Rt9CjKM3yI5JsjSqZd4exjpyiaot8mg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=S9cDNfSx; arc=none smtp.client-ip=209.85.219.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S9cDNfSx" Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e1651f48c31so4631063276.0 for ; Mon, 26 Aug 2024 14:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724707208; x=1725312008; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8BAnUvGPJhPcjr/8DlYb3Io9IRAcd+lsouT0OcFoN3U=; b=S9cDNfSxFVq6v8Pn0syBIkdvOQ0Rx3JwDLA56Ccj7Xe0qhgrdYtEcWkcyaMKMzZRU6 2RiyVTaNql6JFDACdP8Eofa7U1s1HQ8WAomNIa92vv7YELUpMBlhtGRwmpiWtc0NzcUP ZgDGoTZlMmZXdgzxolntvWNCfS2xahaUObUHRnD3AWllBAU5fO7sS+Mgl+ng/OGbqQQj iN/T7zr3mf6y/nxH/mMxFxHOfEjMmt+30gVBEgJ+1pi33TrqFUo526GZY6P9V4bp0ftB +Drx/CzrMsP1y76Rwwl+CtNr3QgjlbbvY5UhOuaDnvR15Kmkrzsb1d2kZ0qjAgOvNuXY Gv/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724707208; x=1725312008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8BAnUvGPJhPcjr/8DlYb3Io9IRAcd+lsouT0OcFoN3U=; b=gMBcp9LNu/3eB2ZYCn5V+L71JIMsHegme604iqRoYhm7vllGR1wuVGyVlv8yVUr43j RRFnC7nxI27FB6G0wB8W9QCGIEhcUrCftPJQAy3MWdU8fXaXKJyvIPbGygK4O2/XcmMU Pc7MyyofMJ1aaopFpRefz/UIcaxqSEabj2W6EJQlqZynUhiB7HughSDdjdVziQ+DVtHP KyN3D4yA/lnwndmJrKrOa4CkNc9C4YTZu9BJFogYzYBeLnr1w0umNJo7UWt7vSO5bbot bvE560zYp7bEHNYWLKwgFli+UqrTTeFPMCr6hu8uweZ1Ph8tyjKQgdj2T+dqGtqS6UvA /V/w== X-Forwarded-Encrypted: i=1; AJvYcCW2sAxbLw1HOCS+3+Lyg/bpUJwgTiWyxVu/thdSVTBQ0lL6rF4M37WIU80uwDbuLD2+wdEvqGnSV1UV6YHy@vger.kernel.org X-Gm-Message-State: AOJu0Yzot+S5bPdxRvnYyuCSZADYBXxKib0SPvjEU9juup4EIXNrI2On vHPh0fYhhAV0iMYK5fglqb4TZL2H67iOTOkUauDK/SZmbf3nEfZiGqSY3A== X-Google-Smtp-Source: AGHT+IHXgvaD6/d/lIQ7b4efIHntL5vyqnZsPo2Wm4Qu782ih1Cp5NnUTB+32crxZZjiom5ZXrgzhg== X-Received: by 2002:a05:6902:2e0c:b0:e11:7a26:29d with SMTP id 3f1490d57ef6-e17a83d4ad8mr12551128276.6.1724707207684; Mon, 26 Aug 2024 14:20:07 -0700 (PDT) Received: from localhost (fwdproxy-nha-008.fbsv.net. [2a03:2880:25ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e178e5698e0sm2214033276.43.2024.08.26.14.20.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 14:20:07 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, kernel-team@meta.com Subject: [PATCH v4 5/7] fuse: convert fuse_writepages_fill() to use a folio for its tmp page Date: Mon, 26 Aug 2024 14:19:06 -0700 Message-ID: <20240826211908.75190-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240826211908.75190-1-joannelkoong@gmail.com> References: <20240826211908.75190-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To pave the way for refactoring out the shared logic in fuse_writepages_fill() and fuse_writepage_locked(), this change converts the temporary page in fuse_writepages_fill() to use the folio API. This is similar to the change in e0887e095a80 ("fuse: Convert fuse_writepage_locked to take a folio"), which converted the tmp page in fuse_writepage_locked() to use the folio API. inc_node_page_state() is intentionally preserved here instead of converting to node_stat_add_folio() since it is updating the stat of the underlying page and to better maintain API symmetry with dec_node_page_stat() in fuse_writepage_finish_stat(). No functional changes added. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index c1e938b311fb..b879cd8711c0 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2260,7 +2260,7 @@ static int fuse_writepages_fill(struct folio *folio, struct inode *inode = data->inode; struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_conn *fc = get_fuse_conn(inode); - struct page *tmp_page; + struct folio *tmp_folio; int err; if (wpa && fuse_writepage_need_send(fc, &folio->page, ap, data)) { @@ -2269,8 +2269,8 @@ static int fuse_writepages_fill(struct folio *folio, } err = -ENOMEM; - tmp_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM); - if (!tmp_page) + tmp_folio = folio_alloc(GFP_NOFS | __GFP_HIGHMEM, 0); + if (!tmp_folio) goto out_unlock; /* @@ -2290,7 +2290,7 @@ static int fuse_writepages_fill(struct folio *folio, err = -ENOMEM; wpa = fuse_writepage_args_alloc(); if (!wpa) { - __free_page(tmp_page); + folio_put(tmp_folio); goto out_unlock; } fuse_writepage_add_to_bucket(fc, wpa); @@ -2308,14 +2308,14 @@ static int fuse_writepages_fill(struct folio *folio, } folio_start_writeback(folio); - copy_highpage(tmp_page, &folio->page); - ap->pages[ap->num_pages] = tmp_page; + folio_copy(tmp_folio, folio); + ap->pages[ap->num_pages] = &tmp_folio->page; ap->descs[ap->num_pages].offset = 0; ap->descs[ap->num_pages].length = PAGE_SIZE; data->orig_pages[ap->num_pages] = &folio->page; inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); - inc_node_page_state(tmp_page, NR_WRITEBACK_TEMP); + inc_node_page_state(&tmp_folio->page, NR_WRITEBACK_TEMP); err = 0; if (data->wpa) { From patchwork Mon Aug 26 21:19:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13778500 Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (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 D6FF519ADA6 for ; Mon, 26 Aug 2024 21:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707211; cv=none; b=M4bwag7ObNyzuJSGI5IMvjNrjDySx02DVm5kbfW4M6ETI5PLErtZNB0qZbu0zihEsjj7y2qbksHLjVsX63xwPJ6MrEQPKYkSLLI+LsKfs7QkJrA5rw78ShdphPB7+5FlS/sxCuQn+pqS9VIfX4aXlN11BPZLK2/XqWoQ8LShTCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707211; c=relaxed/simple; bh=ssIjC0FzFiR5e6vInB5Mt1IP0g4DdbYHZGPZNOSMczk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZXmPFM14snd0QyRPRZl9++FxQJDTpGK7kJ/uhFifq7gCHUaTdHlkx0yrmqA522waHOeP/kMR1I/etVoOUi6XA0iHl61RDnkuRO4ZBf3hCJiKX+C7JwzSrImdlxd23UvAiKBooakJIffHeryx4bb9iQZekm34xkmfs3MVChl0j+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SbC7o0Vv; arc=none smtp.client-ip=209.85.219.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SbC7o0Vv" Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-e13cda45037so5151232276.3 for ; Mon, 26 Aug 2024 14:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724707209; x=1725312009; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1/w6y+HE3p0vEoIb0akm4SHp9YAeENOx9SQfUh1DXgc=; b=SbC7o0VvQGPVqgXs2VhMadbTD+AOPIF06YBT8ZmdyvopEq4a29Tdl6UzYK65XFSu7m h+Ag7BYOcFZIRmwEkgD87qSJDL8sp0tJ1q7/bY7nHzTi/GUDvJ/Aocr1VcdgsnhPDM2k 9Ls3REBleXN42Qrrqcy8PcT4RbWsuJG2lbK5arWUVwkLSZmUxELbCCuUYr1N+P+e475+ 65/qmHY1HxPM+3/Z2I3U+3hOZ47OWzo/PgQ4cKg/sb9okyXx3arXfQnUWJs/5sI1VksS 2pT3dkDQOWmcGrsWJIEE+xA31ltRwo4i+vC8MMpeg8BiEQdUCZXz7vsim6D1jyHU0LKG y26A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724707209; x=1725312009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1/w6y+HE3p0vEoIb0akm4SHp9YAeENOx9SQfUh1DXgc=; b=KhI5boVHqppHbiHd3B60LVbaW5WeGCay27P85F6gSPexg/4qcWrWml9W9+Ni7lue6e 3sMnye02m2dQozInZJJsERBgGf7CqDXocNahJZbccFPiWTccPBY8Tij0AP8nKrZOYqlj i3hkIMvwkFVJU2oA0Z4z6ueAUHhjiuQFzHlDQNrQr+V9g1DmH8xWwGrqm8bvgVDeTSD1 jdtLNDIHtG0+SGBXht/S4KYkpVym82vBKbf9YqC3TS5xeqMcYhH4PO71l8plI86QzvFP 8/Pj2tk+1YEvl5nPlqZo3cv5kiwtaNdTeW9Lsf7CzI8R+SatIx5M9QokDICwR7jqSvsT /I5g== X-Forwarded-Encrypted: i=1; AJvYcCUoEyZBV1Pk7hEWloNSzqTPo7I5TAE+n1JITAp7OjABABU6S2pfNmYvFC8pywfgquZJqIXZN2KQuyP1CtZM@vger.kernel.org X-Gm-Message-State: AOJu0Yx9eCHUGx67SpQueNpIpC7OZ0kWSWYIpEtdC2aAi4UebAJDtBpP HNzteZkkDUHQsO9L7q2tvJmsD4Tx6DPBjsQq+H3mf1+K3EXqPrAiKJ+GOQ== X-Google-Smtp-Source: AGHT+IGbvx3/+YL7vtsIUdHUM08iF0ROzFMACSF/vl8D2OPiAi8bJ9nc7D1hrSFngYy6iU1VxyVZQw== X-Received: by 2002:a05:6902:238a:b0:e13:d23b:f21b with SMTP id 3f1490d57ef6-e1a2a9789e1mr741613276.37.1724707208863; Mon, 26 Aug 2024 14:20:08 -0700 (PDT) Received: from localhost (fwdproxy-nha-008.fbsv.net. [2a03:2880:25ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e178e4b3cafsm2153287276.28.2024.08.26.14.20.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 14:20:08 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, kernel-team@meta.com Subject: [PATCH v4 6/7] fuse: move fuse file initialization to wpa allocation time Date: Mon, 26 Aug 2024 14:19:07 -0700 Message-ID: <20240826211908.75190-7-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240826211908.75190-1-joannelkoong@gmail.com> References: <20240826211908.75190-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Before this change, wpa->ia.ff is initialized with an acquired reference on the fuse file right before it submits the writeback request. If there are auxiliary writebacks, then the initialization and reference acquisition needs to also be set before we submit the auxiliary writeback request. To make the logic simpler and to pave the way for a subsequent refactoring of fuse_writepages_fill() and fuse_writepage_locked(), this change initializes and acquires wpa->ia.ff when the wpa is allocated. No functional changes added. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index b879cd8711c0..ef25dcfcac18 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1762,8 +1762,7 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa) for (i = 0; i < ap->num_pages; i++) __free_page(ap->pages[i]); - if (wpa->ia.ff) - fuse_file_put(wpa->ia.ff, false); + fuse_file_put(wpa->ia.ff, false); kfree(ap->pages); kfree(wpa); @@ -1936,7 +1935,6 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args, wpa->next = next->next; next->next = NULL; - next->ia.ff = fuse_file_get(wpa->ia.ff); tree_insert(&fi->writepages, next); /* @@ -2155,7 +2153,6 @@ static void fuse_writepages_send(struct fuse_fill_wb_data *data) int num_pages = wpa->ia.ap.num_pages; int i; - wpa->ia.ff = fuse_file_get(data->ff); spin_lock(&fi->lock); list_add_tail(&wpa->queue_entry, &fi->queued_writes); fuse_flush_writepages(inode); @@ -2300,6 +2297,7 @@ static int fuse_writepages_fill(struct folio *folio, ap = &wpa->ia.ap; fuse_write_args_fill(&wpa->ia, data->ff, folio_pos(folio), 0); wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE; + wpa->ia.ff = fuse_file_get(data->ff); wpa->next = NULL; ap->args.in_pages = true; ap->args.end = fuse_writepage_end; From patchwork Mon Aug 26 21:19:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13778501 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (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 53FF21991B5 for ; Mon, 26 Aug 2024 21:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707212; cv=none; b=k+wlZHLSuXMRIK5bYXKdzNTBqM5UX4Kw/bIiqdvkqEcx92xyJTY7Ocn9fdrntxszkZ3Bh4tjF1paxsi+jLyRUFMc31A8SK5JUoaUCRTEwIB5WunUANNUvv3cnGQJolDibMab4Acb2qhq7t0da1ycaCUzToqrwrH6HIBZe8CpY7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724707212; c=relaxed/simple; bh=eChdZxLkTEJARF2qLbQQxa8NQysTDNDXSLhFdkso4dI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gA3OYefba4hpcosfE6DpxzL6O7TXVekmLh0jARDIOAlIy4myBsYJPn9agJdP5uiTSznpFbt3bKlDaeq2j1rY+gcAwV5I5WKPC4VSjD69W6wLs1t0C/mhvs3xV98rTFxkRq7P/WoxWLs9bITLIx90S9sPWw1mIpZLM8ePFI3Znzk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=i2veYYNN; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i2veYYNN" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-6b6b9867faaso43147477b3.2 for ; Mon, 26 Aug 2024 14:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724707210; x=1725312010; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/qcJuHgOljrUXDPlcVoeTMfTH5GYtw66c11J96JvW20=; b=i2veYYNNl+lJxGSfPpUIQxIzai8253wmKIT1rXLWOXZaYYkW/nq+VtDdHL15fmfgK1 U+tyEbOrGrXMjaadinoddZBvxm7Wbvq/uaE5+viUnhgXZUznZpVCA7Xci9opEtD8Fhqo V6uCLnbGxLy7qlw9zn5Wn+l1Unmbo6SuHSLTlDSIpRUB2hO4OXdFOlbg/HLqACZarXME xCRGJY+SdBM5VsNCb+y/2GPUMrk9A8+hWS0Vg9XVkGdf0QsVHHc8J9CBL66OYTp1Wy0Y l4PSbT1PGY9BK16nIS3yS58ejznmGRlwIWtb6kJIvRZ+gqQ00MEu4uFvVKj1K81gJ/rv H2Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724707210; x=1725312010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/qcJuHgOljrUXDPlcVoeTMfTH5GYtw66c11J96JvW20=; b=rMJCrX9I17FUSxjTSUJFGHqt/c2oj8oQW0seqPcrAmxQqYQaAx7nhkRAwiwuFfVyys Vfuxvie+oinJNozNZNs0OcRo2PfmR7vND1+1d02Pa8AoJL8hf0U2+mJuqX3GZMdJNwrN GflTvq4Ry5xNq6BuCA1yVIxkTNTzDpwyvFQKdcN0o2ug5ms/xuH3pJ31CVmp961PiwEq pMtWy43+y3czxZJnV6hqlgwrgRaHgnkj2EM4Jb0QYkOGVx05ajro78YVdb3+bOZ4O1JF i4qv3PfYHPvFf38BWFq75U/7VIh0MfMNeAgflW+jtl/WJj9+YcUZ6uXxjRgXw3iySl3J IFVA== X-Forwarded-Encrypted: i=1; AJvYcCU91Xwk3iyvs67NN6QAT/2z/bPeR2jXYcTk23tsZJh++KLb46b6cliLQ+CWJlfvAs2wkJpJKmmHTAWFeyzb@vger.kernel.org X-Gm-Message-State: AOJu0YyH/yg0vQUgwLrye9R3zQqkJjUCmyPkft7Y8lRzIRr+gFVDVbjt ZAwhusAPyKxly4x02DrAX2juyGDbYte8vIOLInpITlyE6mmauMow X-Google-Smtp-Source: AGHT+IHpH6Ec3X4W9B38Xu7L3Ps9O5jbBAzw1yBL4rzUM3mqvjeH5y8HMOGUang9qLvMzFPTiV5Xeg== X-Received: by 2002:a05:690c:744a:b0:6bd:8b0a:98e8 with SMTP id 00721157ae682-6c625f1e929mr150644897b3.24.1724707210272; Mon, 26 Aug 2024 14:20:10 -0700 (PDT) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39d3a9f9bsm16777687b3.78.2024.08.26.14.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 14:20:09 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, kernel-team@meta.com Subject: [PATCH v4 7/7] fuse: refactor out shared logic in fuse_writepages_fill() and fuse_writepage_locked() Date: Mon, 26 Aug 2024 14:19:08 -0700 Message-ID: <20240826211908.75190-8-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240826211908.75190-1-joannelkoong@gmail.com> References: <20240826211908.75190-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This change refactors the shared logic in fuse_writepages_fill() and fuse_writepages_locked() into two separate helper functions, fuse_writepage_args_page_fill() and fuse_writepage_args_setup(). No functional changes added. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 103 +++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 46 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index ef25dcfcac18..726743e33b7f 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2047,49 +2047,77 @@ static void fuse_writepage_add_to_bucket(struct fuse_conn *fc, rcu_read_unlock(); } +static void fuse_writepage_args_page_fill(struct fuse_writepage_args *wpa, struct folio *folio, + struct folio *tmp_folio, uint32_t page_index) +{ + struct inode *inode = folio->mapping->host; + struct fuse_args_pages *ap = &wpa->ia.ap; + + folio_copy(tmp_folio, folio); + + ap->pages[page_index] = &tmp_folio->page; + ap->descs[page_index].offset = 0; + ap->descs[page_index].length = PAGE_SIZE; + + inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); + inc_node_page_state(&tmp_folio->page, NR_WRITEBACK_TEMP); +} + +static struct fuse_writepage_args *fuse_writepage_args_setup(struct folio *folio, + struct fuse_file *ff) +{ + struct inode *inode = folio->mapping->host; + struct fuse_conn *fc = get_fuse_conn(inode); + struct fuse_writepage_args *wpa; + struct fuse_args_pages *ap; + + wpa = fuse_writepage_args_alloc(); + if (!wpa) + return NULL; + + fuse_writepage_add_to_bucket(fc, wpa); + fuse_write_args_fill(&wpa->ia, ff, folio_pos(folio), 0); + wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE; + wpa->inode = inode; + wpa->ia.ff = ff; + + ap = &wpa->ia.ap; + ap->args.in_pages = true; + ap->args.end = fuse_writepage_end; + + return wpa; +} + static int fuse_writepage_locked(struct folio *folio) { struct address_space *mapping = folio->mapping; struct inode *inode = mapping->host; - struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_writepage_args *wpa; struct fuse_args_pages *ap; struct folio *tmp_folio; + struct fuse_file *ff; int error = -ENOMEM; - folio_start_writeback(folio); - - wpa = fuse_writepage_args_alloc(); - if (!wpa) - goto err; - ap = &wpa->ia.ap; - tmp_folio = folio_alloc(GFP_NOFS | __GFP_HIGHMEM, 0); if (!tmp_folio) - goto err_free; + goto err; error = -EIO; - wpa->ia.ff = fuse_write_file_get(fi); - if (!wpa->ia.ff) + ff = fuse_write_file_get(fi); + if (!ff) goto err_nofile; - fuse_writepage_add_to_bucket(fc, wpa); - fuse_write_args_fill(&wpa->ia, wpa->ia.ff, folio_pos(folio), 0); + wpa = fuse_writepage_args_setup(folio, ff); + error = -ENOMEM; + if (!wpa) + goto err_writepage_args; - folio_copy(tmp_folio, folio); - wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE; - wpa->next = NULL; - ap->args.in_pages = true; + ap = &wpa->ia.ap; ap->num_pages = 1; - ap->pages[0] = &tmp_folio->page; - ap->descs[0].offset = 0; - ap->descs[0].length = PAGE_SIZE; - ap->args.end = fuse_writepage_end; - wpa->inode = inode; - inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); - node_stat_add_folio(tmp_folio, NR_WRITEBACK_TEMP); + folio_start_writeback(folio); + fuse_writepage_args_page_fill(wpa, folio, tmp_folio, 0); spin_lock(&fi->lock); tree_insert(&fi->writepages, wpa); @@ -2101,13 +2129,12 @@ static int fuse_writepage_locked(struct folio *folio) return 0; +err_writepage_args: + fuse_file_put(ff, false); err_nofile: folio_put(tmp_folio); -err_free: - kfree(wpa); err: mapping_set_error(folio->mapping, error); - folio_end_writeback(folio); return error; } @@ -2285,36 +2312,20 @@ static int fuse_writepages_fill(struct folio *folio, */ if (data->wpa == NULL) { err = -ENOMEM; - wpa = fuse_writepage_args_alloc(); + wpa = fuse_writepage_args_setup(folio, data->ff); if (!wpa) { folio_put(tmp_folio); goto out_unlock; } - fuse_writepage_add_to_bucket(fc, wpa); - + fuse_file_get(wpa->ia.ff); data->max_pages = 1; - ap = &wpa->ia.ap; - fuse_write_args_fill(&wpa->ia, data->ff, folio_pos(folio), 0); - wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE; - wpa->ia.ff = fuse_file_get(data->ff); - wpa->next = NULL; - ap->args.in_pages = true; - ap->args.end = fuse_writepage_end; - ap->num_pages = 0; - wpa->inode = inode; } folio_start_writeback(folio); - folio_copy(tmp_folio, folio); - ap->pages[ap->num_pages] = &tmp_folio->page; - ap->descs[ap->num_pages].offset = 0; - ap->descs[ap->num_pages].length = PAGE_SIZE; + fuse_writepage_args_page_fill(wpa, folio, tmp_folio, ap->num_pages); data->orig_pages[ap->num_pages] = &folio->page; - inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); - inc_node_page_state(&tmp_folio->page, NR_WRITEBACK_TEMP); - err = 0; if (data->wpa) { /*