From patchwork Wed Aug 21 23:22:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13772204 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (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 786E41494AD for ; Wed, 21 Aug 2024 23:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282713; cv=none; b=uDOqWX7WjSR5S5TVYFkZyAv4KwxtHFGhMioyrtlb8q/5YddBkUpEZ8D6wadgsW9JKWkMF8uVGbD4AMonZLyOFJc9i5w38vUuAneKJl4kwPl7FPCj5hcTSQH0lYC2Mf6+b6ZoPZAG4P4bNTOvKbtD+daz0otP0G+sSsMvBsLsizI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282713; c=relaxed/simple; bh=d1sw3RklYepjEi8jrs758o0Ste9SePDfyolWUw0Jdxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cg/3t4i6s4Qgxxp3se4I1vGncAnUZGu48Aps73eE+ojRAnWXbL+tBRHbc80kBKKT0rtf9k7IzzRagneVgMVOHB8AbDbwN61WZUk07N49pgI+wJYsmCeFmQr8SPUcLypN6Hr9iZLh+TbjX6IJkheEFbDQ8ckmRpYHJvszMigm0ts= 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=IBef7OqG; arc=none smtp.client-ip=209.85.219.177 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="IBef7OqG" Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-e0e76380433so287023276.2 for ; Wed, 21 Aug 2024 16:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724282711; x=1724887511; 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=IBef7OqGu+xHkDppT6SMbo2H2tuGG1Vqf7GLfnHOZFYVLY/IbXAjKLJUEnTRroWLck TWUY0Mg3q0Y2YGBKq5ue3NbtxyKzjhYrea+9cFpsWRZweMiMLKY6HWTjg8Tm77Pz+AgR +2uQPFskuKbA196cY7hBx++DjRvApoefTJs2j9tCyt3gBWaFHDINWt8xCzYe9R6zUu5I NIJoHHm0oxt2WEqT8iOGj8tYzOo4Jzyl6s2TFRFY8tGz8ax36Q0pUdVChNndEW/yA429 3Gi77CaUohtu6imj97eblV+D2H55DgqfcMGNfEE4wWDANnuyicNMw45ZDeSl97DsqJ9Z 7Y6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724282711; x=1724887511; 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=axxPUh7s6P9q8k+sfmI1gmo8vMzC0L1vZBKp5D/uKuMb8bFWjtuByK9VdwBjj+4CM8 Gp0jkd9LP4AQAk6PpHXzpXQg5fLYfQFfKmWgObtdc2T+fywwFisFY7FL3ju9LHn/aKPP VvU1KcS3KjFhLWJna/OLYKluGsNrpb7OX19wmExDROp1V0WVV/U89Am5D9pl66crC78v FtfHk3w4NSGcP5c5qqbif3/kK8VZXHsg7Rp7xf/MNwUVUVP5UQBdwpGcxBMr+6rSMbdm RiDbHGklriO97FcCWCZx9mXGW04QzvJG5BC8jvos30Ymt9MZXNJlt+noWT1O1g4ng9FS mzfw== X-Forwarded-Encrypted: i=1; AJvYcCWNQcDKJqPPG2qxpSIxtfEyFvhkLeBtVRyFdrScGHnLRE4BM9frQUeank7K5cj+cC72qiy+BHSEjeh3nZkw@vger.kernel.org X-Gm-Message-State: AOJu0YyeesTFqzkdNP4feFPzbruMmjkPjK3OZqRR/B3HWKhTDiBT7UTY YlY71uCyfAukc0d0v6/dH2CJyyQdFSUmPLLkZMXXmYn5U1O4HpJF X-Google-Smtp-Source: AGHT+IGqppsTZyTzyNWU0yw6RoixI5lQyS2OvmZ7sGnspvpCmCHu2HXWnUOZB1OlP4IQWOUmpxYWfA== X-Received: by 2002:a05:6902:1006:b0:e11:7db3:974c with SMTP id 3f1490d57ef6-e17903c8130mr192827276.35.1724282711378; Wed, 21 Aug 2024 16:25:11 -0700 (PDT) Received: from localhost (fwdproxy-nha-008.fbsv.net. [2a03:2880:25ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e178e56a2cesm59591276.52.2024.08.21.16.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 16:25:11 -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 v2 1/9] fuse: drop unused fuse_mount arg in fuse_writepage_finish() Date: Wed, 21 Aug 2024 16:22:33 -0700 Message-ID: <20240821232241.3573997-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240821232241.3573997-1-joannelkoong@gmail.com> References: <20240821232241.3573997-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 Wed Aug 21 23:22:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13772205 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 C7B65170A1A for ; Wed, 21 Aug 2024 23:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282715; cv=none; b=b1aKb5MMxJTehitiU5b3ibjthyiPCGwf0F9djVo4s9BDfT4/YWnObuECMSP+jFCGvPddPa67iBOkJ8duy+0Ko4JBBMRyne7CGjLiwPahj6GpyPD3LtICu5GR0NgwbCoKTWWkWMmy8vEvX3ZHapyc6Vl7aRq9eH7PICqoWTANakM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282715; c=relaxed/simple; bh=UWKsRqn8KEexlFybvj1D8QiH7e2TeVsMe7AUmeAODaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LMkFChjVWQ+HOWv4gfW4KA4ErS4Sy0gJj+yAikE1SDIPcIRJ9S563YUO2H8rxprrGSGyx/kCibrGqfM5HuWDr64RuwXLwRWs11Lxe7WLs4efqQ/YDEfltFBqY8e5Q0htgHR72zn+WKXOgj7oduGaDxweIK+lIgvkwbpixDcdfWc= 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=YHTs+8hS; arc=none smtp.client-ip=209.85.128.180 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="YHTs+8hS" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6b99988b6ceso3328377b3.0 for ; Wed, 21 Aug 2024 16:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724282713; x=1724887513; 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=YHTs+8hSlRhfhNmRfm8tt5OPhCZWypQKDsHqeZT3dtjSi67TtMY0Ra0AnX+52SGbLU dZACARvGzeDmNiKfbFjeh9vvqaag9HrTPQeWJfYXr8HXj+IVaAmu7m09F4aFqIUu3Aiq TdOZWfnv/2QG7wlEpVo3jWXxjl+FI23BG+yCFM8CEfzHgaYKDnYwWwqOK9qqELwOBeLd phO9gHMpod9WmnSAArDM+Lnf9vja3sG+6eWfVvoYLp+q5j+RQeBlHC0guK9Prn8Dy+0R v5WLFM+P1YhT7ceVKtq1a64Eub/kNprkNFBsP5B0mj91P0zRGdDoQUMV42Z0aKRHaMS4 62EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724282713; x=1724887513; 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=I+QB7fAU8YV/AW+esrxecwis9Q6l0P3979vgYL887rLlRdvS2usbtH77tyToT77/sq q/J1cFjn3mNtKOA+PrGxQkCQVPkeSLOI4KqF67gEUR8njVYbv0nzGGUNaa9JIual6DFz BrDY4CBv0hJEuFaBopW+juw+tzU/plB6azqZ+RKwm3nnQr9QhCNM7qXZuVqgmoS2wL1Y X4ht3v0EHs99QaeNFuiRrFym8ycLAJ1CMC15aUudYiD9feDMQa0ZT3gjSnRIp1VBH8cL g825fpmfstkwGZAGPsEX+2aF1nJDf059eETILSUMtzGaBwVh31ipbnmcqg0uUDfjKJOo TikQ== X-Forwarded-Encrypted: i=1; AJvYcCVWq2yao5je4AYgBjqRaVovXKke0vj5/TyifKSBQ/f5dabFNbhnhpgpNCI00p6ze/vKaqn/PjCHLddgXmjP@vger.kernel.org X-Gm-Message-State: AOJu0Yx9yEcsPoq/h0mPe1OMWae5rLCtgTlMESfJOxkHYELSVOOtxFVr VNd3Cen8DBbZCv7hQiTbbDR0Tr9yeQ3y98+TbD0pLQRxzszdxyT2 X-Google-Smtp-Source: AGHT+IHbAVsleOn+fOSVF50yjVBAd27OnAHiT26U0ZWK1/+h5Oq6DSWTNjsR1z4H+0SLLlq8oxJ6Qg== X-Received: by 2002:a05:690c:d93:b0:64b:2665:f92c with SMTP id 00721157ae682-6c0f937b4ebmr46798587b3.8.1724282712671; Wed, 21 Aug 2024 16:25:12 -0700 (PDT) Received: from localhost (fwdproxy-nha-116.fbsv.net. [2a03:2880:25ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b00746csm383427b3.67.2024.08.21.16.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 16:25:12 -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 v2 2/9] fuse: refactor finished writeback stats updates into helper function Date: Wed, 21 Aug 2024 16:22:34 -0700 Message-ID: <20240821232241.3573997-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240821232241.3573997-1-joannelkoong@gmail.com> References: <20240821232241.3573997-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 Wed Aug 21 23:22:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13772206 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 322AE1494AD for ; Wed, 21 Aug 2024 23:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282716; cv=none; b=LY1b1FcV/Ox0hYU3UVJUkKG6tQaVxZWY7SbDRvBZQxIGglmkfo5arCJJ5SVpLQQqbhuVliHi4/8INGY9kEptLLvpiQJtiOwgG79pkz7oGvG5zoruHmMk9E9m5eI61P076OrHcYfRHqqWwi2Iga4nOLS53qgkrIxxiW6Xbl3Bm78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282716; c=relaxed/simple; bh=eaHwMeJ0CTx8L8hGmD/ZgvwlqQiriDj4xMCy/d865M4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j4nHv8AfeR0PjWmX51sNi9gvyZOOCdAalCUwBHUGgypr8RB/wGjlqxLdH7+0uGOFEVGuAiQRJZdz5YfzdofgzFOcaK0kIngTW8JHg2gRW2tQdC6ym4YSPqWzsE5+kcA2re7lKACWllRok4LayEGTwd3nOZon9MHst6shPWEG2iU= 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=Q5DnVXHp; arc=none smtp.client-ip=209.85.128.181 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="Q5DnVXHp" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6c1ed19b25fso2507697b3.2 for ; Wed, 21 Aug 2024 16:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724282714; x=1724887514; 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=Q5DnVXHpqc3Ca2r2NFLlpCuYNwtBDU/lRHSAlSWcbDZpcyJQb7ugJnDUFt9TIEEUOF eLpwYVAQ+dNsGQZHC5yD6twY4W0JsXwx24kXQFsa5eReo+2GTfjsNVw4inu50hBuT8l1 M+dGDhPTGRV9Y8tvfvnGqBwA591qFFRfQL96jIE/6QCa+R4iy2Y3xpEm4KLqtveLNP0X VN1klMZy3UWOAGmeRCqLyjkYdny1HrDwsBFdiJNvadqtdGIW0eFAuVdzIrIzLGzShTtv n+LT/xLBcsYgzJDZcvPsPjb+uUXPxfp+dVtdjQTGQB9s7W7r9xujhQoX1BYefOj/eGpQ dUZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724282714; x=1724887514; 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=q/ZG7dZsccTn2glq3HcsPIfKzYFFBUqJChid+OpDkdV+urk4OVKpxLZSj+9Tx0L5ya VPOFdunK6vyA8g0QBP+y29b0g0+/VhDa6c7BmphQoHlK2+G8RqW9U/oMF8gwWfhvyh2H 2uYdIlt4R5qnn7mFPhw55YV3AV4a9o0TTYgbnO8WNehNe8QVQj7YMdPrIE8vyHV0lS2y KZiGnoJprYf97FV2Jp6uTKCsyNoOqapmPl+RyYlfqM38+9MiPCOwDxPg0wtFQHIP4gyx G+Ztit/wt2YXtIvV2U+zZkOw09GFgxxDFng8UHTl58uC5RCw/dpuVRssWhL5aJjbLQA3 CDLQ== X-Forwarded-Encrypted: i=1; AJvYcCXwYqCeVt3YFmOBic4xSlaMUQ0jdjI4vYrxMnI3zrvy3wEF3whRZKDIE/w8XkPreRjF2qvK4Fx8HugLvkuN@vger.kernel.org X-Gm-Message-State: AOJu0YyX1Uv63W/hOM4A774gt1PSbH9KmMh34b9+PGxB8Xxh+fvYo5HL 0VxYO49vz88Ikf/1Zb4rN9D3VI629Zc1En52gd/H//DO2ltXgIMv X-Google-Smtp-Source: AGHT+IEmtXQDt3MigRFJZs2cvOMaTfsxNs0BPdApvvwLL2IqHWCZ2oIg1bUZj3yG1K2CiIa5Kfv+8Q== X-Received: by 2002:a05:690c:4b06:b0:62c:e9f8:8228 with SMTP id 00721157ae682-6c0fb268624mr42255447b3.25.1724282714062; Wed, 21 Aug 2024 16:25:14 -0700 (PDT) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39dc531a7sm365987b3.126.2024.08.21.16.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 16:25:13 -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 v2 3/9] fuse: update stats for pages in dropped aux writeback list Date: Wed, 21 Aug 2024 16:22:35 -0700 Message-ID: <20240821232241.3573997-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240821232241.3573997-1-joannelkoong@gmail.com> References: <20240821232241.3573997-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 Wed Aug 21 23:22:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13772207 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (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 620CD170A1A for ; Wed, 21 Aug 2024 23:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282717; cv=none; b=jF/bxfsPiEFWX5ppPki8BkFmKNZ9TxG5nJUvHp6J31tbyUrAlkER1KJh7Bz4fjkXtLVvyFqiIiOVThb9OmMkCuP5J6TVnnP0QdfsNYvGEdYUQWdKiEn5uiM+uMGQL8No8/Bu/Qgo5o8wlFwwt7nfgq34CGu8HdcDa9lkLRvW9Hs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282717; c=relaxed/simple; bh=s2ckAHicpl/to3zXFLNJePIx3hN+gTnQ2xFFhBBYmXM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CBj7DuzxOpDDktFcf7SfEixCAZITceUyV7/rkvJIfVfDfqiMriaZ8jcZP9dKQLUhsseHZHqHnHOkqkdIQkU1g2tjLLxuSwVtliQFzj5M/Z9Oh3zMFAYxyhdTEsxcK/2jhsbqMQblvqDIGs6duPPycBjFhH0SBe4AOWil+ID/xR8= 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=YkzbHZxq; arc=none smtp.client-ip=209.85.128.177 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="YkzbHZxq" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-690ad83d4d7so2526837b3.3 for ; Wed, 21 Aug 2024 16:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724282715; x=1724887515; 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=XkDoaQxIl0z3f0TI7q06kib98oK++nBTzRFtBSj71EI=; b=YkzbHZxqO3dBOKZsZlqXLmpTREr0b1ZSORE6OdwnY8jROoLps46gADBWGdibcutUYF CwkM3zJIChnbS7ezf4m5XhuLw8WHO/E30AZMIpw6l1Hr6S3MuKaoRTTZh9LrI55fZAA4 Ou4mJoZDfIDg4QgKfqzHcoixYB+h3HMs2d2R9r7lV+W5/AsJX+oKDxTEUERqN6nUtSof yfZ+O0QdLRLomoXcJY1rMF13vgYnGz2N2XjloNSdqkfZK+SolzGRbi2WvmVw2ZrNADgJ r/lxGyyockQbm5yND7qX+6tTTEQ0qzgfzqQEBA2A6VYzQ707XVb1zUVmBy34HIGvo1N1 w9DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724282715; x=1724887515; 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=XkDoaQxIl0z3f0TI7q06kib98oK++nBTzRFtBSj71EI=; b=Y7G8zW6ERYmc9+T7r3iltEDiM3X+2TWX5wHNUwEsijFABpbcWcbJfdV4zpWnlFgF8F X7c9BRgIn6v4OTf4CUIttl7dX81VZ85ga4SluL/gsocjeARqlEl822iNzcgVdpTMcpeD wlS4WD1klWzt5ivazVDVej4Mu/O6dPaSgbs9eJwDf9FLmjcnd5vpL/vHoYg7f2n1idmM zl41367g5tyepPFVJexI2kq4wnmaprqW3Ho/863cXc5+mX+4Iu5jVk6VlFXehPotXP3c qABtZZMjatFR7O9SKM2XKzvjM5m0SwVfhOMe3RbpVikmWinMiyCw6Caepjg69SzAdQ+s /Fjw== X-Forwarded-Encrypted: i=1; AJvYcCXxsn5bkNM8SUvjk5dCxKmIuPcho46xk2Upod93FlamH9M35d6oABklrYEYrMdGMAY92j+FL03ScqsiJcY4@vger.kernel.org X-Gm-Message-State: AOJu0YwTpVV90c2vF4zglNydi9rLqmiXigRC1XQ8AEsPjwS9N8MDIDv4 GlfQ8F21iJz2Jhc0jmTxHrLs2oOMpk56BgdHz5dq7PPOyc0REEin X-Google-Smtp-Source: AGHT+IFzOCRaarVq2sP/i94d4/Oiygq4RGt7eXVHDo5nlwXvtImjoZu8b/eWPOTXqpspsedwwuvXSQ== X-Received: by 2002:a05:690c:e:b0:643:92a8:ba00 with SMTP id 00721157ae682-6c3cbe8adf0mr1241187b3.0.1724282715301; Wed, 21 Aug 2024 16:25:15 -0700 (PDT) Received: from localhost (fwdproxy-nha-004.fbsv.net. [2a03:2880:25ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c399cb569esm396877b3.14.2024.08.21.16.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 16:25:15 -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 v2 4/9] fuse: clean up error handling in fuse_writepages() Date: Wed, 21 Aug 2024 16:22:36 -0700 Message-ID: <20240821232241.3573997-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240821232241.3573997-1-joannelkoong@gmail.com> References: <20240821232241.3573997-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Clean up the error handling paths in fuse_writepages(). No functional changes added. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 1ae58f93884e..8a9b6e8dbd1b 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2352,9 +2352,8 @@ static int fuse_writepages(struct address_space *mapping, 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) @@ -2364,12 +2363,11 @@ static int fuse_writepages(struct address_space *mapping, data.wpa = NULL; data.ff = NULL; - err = -ENOMEM; data.orig_pages = kcalloc(fc->max_pages, sizeof(struct page *), GFP_NOFS); if (!data.orig_pages) - goto out; + return -ENOMEM; err = write_cache_pages(mapping, wbc, fuse_writepages_fill, &data); if (data.wpa) { @@ -2380,7 +2378,6 @@ static int fuse_writepages(struct address_space *mapping, fuse_file_put(data.ff, false); kfree(data.orig_pages); -out: return err; } From patchwork Wed Aug 21 23:22:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13772208 Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (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 BAB811494AD for ; Wed, 21 Aug 2024 23:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282719; cv=none; b=XB5Whfd7LmIFJo/sRcqjxZIpZJ5tGW3juqztryIiboJywajigqTlAcUXlmC7oQZB0EcPXj1zNG1sBEg8DAWs2UJrjGbRoBO3wJz1cANXli4W33y7+9EIimu2EDtZyLiDLsKmtT7tNi5be0ANJJMzMTWFysTlexAlnR8W6sBmQXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282719; c=relaxed/simple; bh=HWgCgryQWKqUPf1F23GgzyxFpEVzrg4+0deuTRBk/8g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cIt7aY28ySc+CAXcwI0xwI4Fjozer5x/Dt0XJ/nHbfExXLFIdxUexyG7xYAKzuiW+Z+/W+V5jTR3DAYFC0nSxpn4K5srY0QWf1hWR9B2yfAIYhVqDyBw266/JHCf/ZVKA9ih2Y+Kc15GKJfsVVZ8U1REM3RDyLck/0Tcq9y6UTU= 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=RM3qbp1v; arc=none smtp.client-ip=209.85.219.169 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="RM3qbp1v" Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-e16582cb9f9so183903276.0 for ; Wed, 21 Aug 2024 16:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724282716; x=1724887516; 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=lWSf9y4vnGgRe1UtTUvWGOAMlUUVPnm9f7sh6h6bro4=; b=RM3qbp1vXa3qf1VCwA6Vew17Ieatq9Hc2+HW/qr6ScUFrzEaiL2Wu+MDKuzKnDjAYn tGo4ZR59yAXsnJgctMdDIWVI/k3zh14EZFOaLdoIZYhuL50zH9XC+OeFM+Alqfe3ry9k tfpKGyxQLN2Zb56wyiWqFP1U+9OFezuKXhMdq4OSvTg+3/uVV7P2Yq0cjCjoLVDqkjR5 cZjKsKqmN3OVEdsjCkfjag55UxfZ03LHp42lZONBLoQWobbc5rhhWonVLyEJHnp6noUq Wa6Sf0Di11e9WYNKkhDWIG+8ubtmCpONeSLSbCitqEmu4wVu+zru403TrhqlEjwovl6B hO5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724282716; x=1724887516; 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=lWSf9y4vnGgRe1UtTUvWGOAMlUUVPnm9f7sh6h6bro4=; b=SymlJ3niRqItgD6VSXwQsUllFvspQV5NjDW+Um3GuNjuV+d8EuOUrq9eveKmU28bLV mYnJl/hbQsI2c95dviHMPyK7/C9FXV/9vhYl/DQwXoBnEkXyua66nE4dSlb2cSFMvMOS eN28SbQjXi58wdxtnrFiQNzpB0Hws+q6MsszrPFC1Iqj2O1RVgzsV9zBNBOIJ3r8HYTF vl5iZBGiVdH7L9xKjMX32wH+EKxherSMG/iAbo48y8TVWQXS707XN0Sn+6CRc0u684Wj 65cqDDcFD7ancwdiz4w5CpfPW3Y6IrZV0Z23Agcr4ZDv1iFt0T+h/g/ZX2jyg+CjrnMM 9WxA== X-Forwarded-Encrypted: i=1; AJvYcCU81vz1Vg6nZZi0XRDSfcVViibAcZRw/2aQURCxxogWTh/AuBGQ3LuD2kJ90F+ly1GDayzo7yJUT1p/C5NV@vger.kernel.org X-Gm-Message-State: AOJu0Yyy8lTOpu4s0GMjuwSoORDevcE/9XFcYmXUis/VSKEdZBvd/0Oj rTzu3mOjO6uyZr2PL6mErya2nMAf7ZxdYKfo16t/UZcBO2msQe8N X-Google-Smtp-Source: AGHT+IE0DmLuZ41ciAIo1sTcFw4sAEG19VFaf0/TxAp+RiC4MYEkN5l3IbUOIh8d/qjP66CFmZuMIQ== X-Received: by 2002:a05:6902:2288:b0:e0b:d2e3:4da7 with SMTP id 3f1490d57ef6-e177e0ca53emr1252154276.18.1724282716617; Wed, 21 Aug 2024 16:25:16 -0700 (PDT) Received: from localhost (fwdproxy-nha-116.fbsv.net. [2a03:2880:25ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e178e6813e1sm56555276.64.2024.08.21.16.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 16:25:16 -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 v2 5/9] fuse: move initialization of fuse_file to fuse_writepages() instead of in callback Date: Wed, 21 Aug 2024 16:22:37 -0700 Message-ID: <20240821232241.3573997-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240821232241.3573997-1-joannelkoong@gmail.com> References: <20240821232241.3573997-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 | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 8a9b6e8dbd1b..147645d7e5d9 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,6 +2341,7 @@ 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; @@ -2361,21 +2355,25 @@ 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; data.orig_pages = kcalloc(fc->max_pages, sizeof(struct page *), GFP_NOFS); - if (!data.orig_pages) + if (!data.orig_pages) { + fuse_file_put(data.ff, false); return -ENOMEM; + } err = write_cache_pages(mapping, wbc, fuse_writepages_fill, &data); if (data.wpa) { WARN_ON(!data.wpa->ia.ap.num_pages); fuse_writepages_send(&data); } - if (data.ff) - fuse_file_put(data.ff, false); + + fuse_file_put(data.ff, false); kfree(data.orig_pages); return err; From patchwork Wed Aug 21 23:22:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13772209 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 0AF14170A1A for ; Wed, 21 Aug 2024 23:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282720; cv=none; b=UfIdNQ3SByZjjm8v3yaeaKBsvKSJvfyNkffF5Q069F2pUhbHu9W8M/xhMul6oRMlf1YggQ95GGj+SK4oOwZ4BFG+A31c7tLkBQa53E90yjcVzQ7zXm5rndMG/jwYKwFbGNqwMeh27o0UwObnPBRlJ9QJ05+LhkrZJ7vYRPEAsjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282720; c=relaxed/simple; bh=HWmEGAi1o/pVlJjLY2yfC12lSn6kHGJSjR+sKLPRtpU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YPnWUoZ/n4C8aBF74U1XalGUIw6E+58iEEfWyvBVt9xJfxPzGMHujCaxqeQtWKdopoRdJafcA8PFkdeTkVU5GGUBmKglj/2TNhYSo5rsq8/DK06kL7KrS0MZAWc7VVUiIuQqjR/bkaEGinL9Fi4NTLrQs5DORT4mq9Uqdtg3z9w= 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=hYFWu9/B; arc=none smtp.client-ip=209.85.128.179 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="hYFWu9/B" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6b44dd520ceso2874427b3.0 for ; Wed, 21 Aug 2024 16:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724282718; x=1724887518; 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=HJj+pqgKJn3s2nA/qlOtlmtIPaAKsgqF3PoVVIX/LxM=; b=hYFWu9/B+n0+tNtp7+c0mFNXPLFcirmvmpagDyxWWXafG0ETuPi6JvWkFAFfhTBuEM KUsDKixHv9E5H/VN0Ql5vpSvsjBBKnUNSD+mC46AOEmbl8lFL3b/Ce6rtqF2+GPRQ1Hv c877vS7Iy8YDjU4o3wKq0l5og3QKQHfdktERPEpzLCCaZt71rYN3iy9Way2nbfSleWe9 gNxLcBn/au4D//qM1rCAljV5XscObNWH2X+4SzPVbG6gH86UNUULXVEVbQogaPP8VXJV xLfhaja2OjgRDg8LopEvkJJFh7KQ0aSQOvgNTiXv1s1+zqaMryJmk+gG+BRti2lQRdj6 KIAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724282718; x=1724887518; 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=HJj+pqgKJn3s2nA/qlOtlmtIPaAKsgqF3PoVVIX/LxM=; b=jwojKISGKvkpDszZGFbLm0UXuxuY+SU9+da+1D2WCRTxcJsSGKT8wG6jUPhLrI+v9H Tj+GyxAjOdG2GYhVPNb6aB73SBHK5xXmQ4AZU2tkzdyQiRW0crJ7LnaqM3mnDqM+s4hD 2gRD8M+junKfRh+h4hHQadtjgXjYBbdjYQyQVNmyfiHHt8gFdg02LW3pmVt0gm1L1hUm bu0tkFAj09PAW4q/Mc+YJDyAFNeE+QYfK/ix6I30f7r/IfuvR25hk0IEYf3zVawCH2mV r9drbuaj4szIEWlL3xWom7/e8sfrGp1RKkAiKESI5AXeyTMM4oV9YgLyL+0dznZXshrr Js8Q== X-Forwarded-Encrypted: i=1; AJvYcCVBhJAGnplx1C2TgRo9krfgu/reRPxsw3v52EJeGDORTAiWxnmJxBA3RbTreRcNTnXaNFSy8IlzejK5z0DY@vger.kernel.org X-Gm-Message-State: AOJu0Yxsz9zSYJ/rlp3r0wd1VnEVpQxB/xfwk04hxDK4CGZQExvHBdsq dhYI7yC06vg4YWEml+GrsscNcfQXtxKfvi9pDfT+ObERmktrqKuQ X-Google-Smtp-Source: AGHT+IGLbQ4G+vFKlURbt4IMDQML2+2i/X2dzMj2Vabd65s2nS+7qbrouMW453zSlmQyOZ0Ixo4TAA== X-Received: by 2002:a05:690c:d91:b0:6ac:f8ac:7296 with SMTP id 00721157ae682-6c0faba0ademr47087027b3.1.1724282718037; Wed, 21 Aug 2024 16:25:18 -0700 (PDT) Received: from localhost (fwdproxy-nha-007.fbsv.net. [2a03:2880:25ff:7::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b007afcsm383887b3.72.2024.08.21.16.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 16:25:17 -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 v2 6/9] fuse: convert fuse_writepages_fill() to use a folio for its tmp page Date: Wed, 21 Aug 2024 16:22:38 -0700 Message-ID: <20240821232241.3573997-7-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240821232241.3573997-1-joannelkoong@gmail.com> References: <20240821232241.3573997-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 147645d7e5d9..113b7429a818 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 Wed Aug 21 23:22:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13772210 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 2F7F317DFF5 for ; Wed, 21 Aug 2024 23:25:20 +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=1724282721; cv=none; b=uG3CMtb2mhq4fzBwZJP3/P9iqZ2nWkFxLK6gJr6Opn2QlCVRaOI3aXc8ACPEVN6ovVjaR10YUubrRR2sqOJ2saQ8BD8ZK5Fik3WNb/PXdVPkD+2nH5Kk924ADNeHTY7Gx8GOhQ8WchEFj7v+UGzvm04GhtF0Wvb/5Zxscc0QAVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282721; c=relaxed/simple; bh=AvGQ2/ApBbWCF0FR4kKYvKKwB6/51/NSgtC96l4Pp0w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HmKo9fzzkp4hPhm4J0BOD1WigKQ3sgXx/f0KLv8OsgokzZCIqoELB5W4A5supv/FXYhx2Cdw6A+PrH5E1FiY8DdTgNRny8EIJNNq8LL6LvWmMAFYvpTOrtKVtbmzjR4TLGSWe32Id55WcWD3dc9PlKSHUgbr47w4FMg2jy+6bfI= 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=H6DboccK; 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="H6DboccK" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-6b44dd520ceso2874607b3.0 for ; Wed, 21 Aug 2024 16:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724282719; x=1724887519; 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=gbaJT4tVpba03OH7U7d5AXfEsyZGDpXKX9B2OFgYQIE=; b=H6DboccKNgZNbUzdPUiB/cA9trXBJhgj/2rM9crIFClScxAslmtoVIF/zgbffFrPKq FtM4KuLAtYv3AUu12OAYVn1hg6vwmC0g0peI7jeQb3ebGQfDalqW1Sc2aOC48YorlSVb SqVj98punrCLu/HRF4M0Hrz8QoXPD0E1ri1JVBY/TPxmKipeNNlugMJ184vI7H4qc14c gKOTI6GOYp55y4R0XyXqC7aYqQ2TnG2X6JyjgjrwfmORsWOdSlgeKLkptU6rL9mvdgIQ sTt4iksEFcQbCD2K2qkBpEcFwcZsoqILBJJkp0AwIT6dEbdIcYI2kIdzn2Iskw0NfHB4 t+WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724282719; x=1724887519; 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=gbaJT4tVpba03OH7U7d5AXfEsyZGDpXKX9B2OFgYQIE=; b=t/a2fiDp/xovg/ygs0yVVvpK+OlrgsTig3qREa2bZVKlmGTuMzAEAhVSExQfU26PL7 T50GJjtOK8SyPKvJjgG6neDOjJlazWBA9PHwOa2xzbh0NIN83PhguUE7Pzx8++Jz30iA rjYWysQ9hh47rxYRhHQg4q3CC2IDIxXYhpN45t79lxy6aZ5ZsvMpU+S15elj7IjYekxK Ou4y3JkOzjA/YDbtMxtwG/V2v4A0v+danyzXG5OU8UD+L1jDqBug6zzY+CU/oyAJyVb5 DeXjSNp5fjyqt3K8O5ktLZvThOUF80P1IOJ3Ml6hiKAXmUNCgpWYX4gTp+E5L58jdMN+ DtQA== X-Forwarded-Encrypted: i=1; AJvYcCVYUfLAwHrdDu53bO8MelwnCfQbuXVKZdDmNMDVIjqKSAiYhnx5LmJk1ZTF9Xd6dISOpjJ4OKSALD5LYSZy@vger.kernel.org X-Gm-Message-State: AOJu0YzgIRyl6mguQj4O3TdLbY/B4zy29P+Jcwu5D3RLES8rZ6LBjVMT CyzEwne2DqXTuvZe4q3UJpWe7fU+r2zWR/3u1wf90cCbPC0cXYXXVIyLAg== X-Google-Smtp-Source: AGHT+IHjJTVR+Tan64fSPCMHyvBxYGXeXQTYXx2TNasECeveD7Ze91IPztRycNo3foW/gPBWh+Cr7A== X-Received: by 2002:a05:690c:108:b0:664:5957:f7a with SMTP id 00721157ae682-6c0fb640ef6mr45626757b3.15.1724282719197; Wed, 21 Aug 2024 16:25:19 -0700 (PDT) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39d3a9dfdsm374087b3.86.2024.08.21.16.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 16:25:19 -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 v2 7/9] fuse: move folio_start_writeback to after the allocations in fuse_writepage_locked() Date: Wed, 21 Aug 2024 16:22:39 -0700 Message-ID: <20240821232241.3573997-8-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240821232241.3573997-1-joannelkoong@gmail.com> References: <20240821232241.3573997-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Start writeback on the folio after allocating the fuse_writepage_args and temporary folio, instead of before the allocations. This change is to pave the way for a following patch which will refactor out the shared logic in fuse_writepages_fill() and fuse_writepage_locked(). 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 113b7429a818..812b3d043b26 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2060,12 +2060,9 @@ static int fuse_writepage_locked(struct folio *folio) struct folio *tmp_folio; 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) @@ -2079,16 +2076,20 @@ static int fuse_writepage_locked(struct folio *folio) fuse_writepage_add_to_bucket(fc, wpa); fuse_write_args_fill(&wpa->ia, wpa->ia.ff, folio_pos(folio), 0); - folio_copy(tmp_folio, folio); wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE; wpa->next = NULL; + wpa->inode = inode; + + ap = &wpa->ia.ap; ap->args.in_pages = true; ap->num_pages = 1; + ap->args.end = fuse_writepage_end; + + folio_start_writeback(folio); + folio_copy(tmp_folio, folio); 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); @@ -2109,7 +2110,6 @@ static int fuse_writepage_locked(struct folio *folio) kfree(wpa); err: mapping_set_error(folio->mapping, error); - folio_end_writeback(folio); return error; } From patchwork Wed Aug 21 23:22:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13772211 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 7769117DFF8 for ; Wed, 21 Aug 2024 23:25:21 +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=1724282723; cv=none; b=i2Rk6AkQ+5vmogYlDtGSEvkz0DfAq3bDgPPawgP9ULDCYEGM0blWl4kTvAI1qFx0v1U/VDEedC3FiZYUeKZPnPJGeOR9i1CV0P1NdqickCsaUIvxpAoDySgKq27rPUloQlcGuq8AuMxvcXP44gkBrLe8fDhwmEjAgxCdHWbZrdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282723; c=relaxed/simple; bh=gKnJEZT11DQ06ikXb5oMR9t2opeJf+EppgH5eyD1ZRc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H92wsrg4Tw7pLuOoayXY4SpZK0mTYGX5T2Qrm4Q1e8RyhBulzR8mH9llK3rWlXnVZY5IGGpc2lB7pEyxV3R4PQmxaVI8w98HpqhLtBDZyx4I77ifWj2gYbAKxsBtqIY/blq0RJMft2rkGxDI8XWBrfSx/G5gNxd0f/MGqDq77NI= 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=Qvw9f7qd; 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="Qvw9f7qd" Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e1633202008so268166276.2 for ; Wed, 21 Aug 2024 16:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724282720; x=1724887520; 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=Ak2ie9HoEpdJU0+WPVOgSdaEsgb/FpgyBUDlSUZ5YAE=; b=Qvw9f7qd9VadgtYu6uN7xHzcYCDHMYFk9n6tkAyVqqWe3LX5l7gaAX8skangWMtaLI 2ba8TPcoqICLT2Q4uBdc3BOE/OArC8yVWXxe22Wv4metouWyTIV6+7pjdsobp9ri7a+A fxpElJiotCzsdfqQTK+6GbKNe2r5pwp5yTmUcsBDOS5RVmK+SuM8GbUo9Z6Ho6WgWhPg ThwmJ5YW/e0a6Bo//yxcB0Nx+HBrIgLSVrNAu4grDSkEryP1DMlSqKMXdRaB7/j+2CvW weSied9zIOgLXrdrCMzGuAyAlA2N94nztpu1RbEAKvAUshRAcpYn1Ry4hG2Q8aFuIRMe RTzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724282720; x=1724887520; 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=Ak2ie9HoEpdJU0+WPVOgSdaEsgb/FpgyBUDlSUZ5YAE=; b=BlJuTpqjrj1gLVsIZ7HUTUJKBLAOn/TlWVNaJxkVD7m4Lu7nTsiIonu6R1wo/6VJiY iltNMkldemhuSYHXdmZbhC85zq4otT4640gwf8yup96NkEIxaYSzfgc8g7U9JB4SX+Oi YEs3FGXO0qpZ4qdlbQf0gsKqzx5ETGa4klPok94aKx2YJbD2ZrY5R1lemxmtDhz1qsg+ GrS+wiVif4mv965BqKChWk4HrrazFiNs6dJoLVQA6e4eLqSbAg8Bv/cPHVJhIRQgrH5S R6tjPifTGT6QBDaGufePUXzeJpb5hUs2g1mA2u/UykFB/jsWk4ApZP8Tz+q+cY6qzeCC pa2A== X-Forwarded-Encrypted: i=1; AJvYcCXoFrN/ZdK5ZtZJphC53cVl4yZGtgHUdE9/WpN4GAngUNWgcOMKZl7VpDOLzpqed+CayWZRocosiMhNjx1V@vger.kernel.org X-Gm-Message-State: AOJu0YzhAoxqJR7SIY0qMXE0tFRLBmEn0fQmMvwWWKV8fcwT0UC/nFKJ qAdTOVqT5/5DoIriU9h3ilWF3oPlEl6/fjioVcJo0vCmRNSBjHCX X-Google-Smtp-Source: AGHT+IHI3qyK+9Y9cScldatv7aKCjzXQuor0IohDwmD6ZLytNawzLCFZD0f8sIfSK4eS/eBmdxZY2A== X-Received: by 2002:a05:6902:2013:b0:e16:4dc7:aad3 with SMTP id 3f1490d57ef6-e166548bf93mr4029464276.27.1724282720407; Wed, 21 Aug 2024 16:25:20 -0700 (PDT) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e178e56a2adsm59324276.48.2024.08.21.16.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 16:25:20 -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 v2 8/9] fuse: refactor out shared logic in fuse_writepages_fill() and fuse_writepage_locked() Date: Wed, 21 Aug 2024 16:22:40 -0700 Message-ID: <20240821232241.3573997-9-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240821232241.3573997-1-joannelkoong@gmail.com> References: <20240821232241.3573997-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 | 102 +++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 812b3d043b26..fe8ae19587fb 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1936,7 +1936,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); /* @@ -2049,50 +2048,78 @@ 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; - wpa = fuse_writepage_args_alloc(); - if (!wpa) - goto err; - 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->ia.write.in.write_flags |= FUSE_WRITE_CACHE; - wpa->next = NULL; - wpa->inode = inode; + wpa = fuse_writepage_args_setup(folio, ff); + if (!wpa) { + error = -ENOMEM; + goto err_writepage_args; + } ap = &wpa->ia.ap; - ap->args.in_pages = true; ap->num_pages = 1; - ap->args.end = fuse_writepage_end; folio_start_writeback(folio); - folio_copy(tmp_folio, folio); - ap->pages[0] = &tmp_folio->page; - ap->descs[0].offset = 0; - ap->descs[0].length = PAGE_SIZE; - - inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); - node_stat_add_folio(tmp_folio, NR_WRITEBACK_TEMP); + fuse_writepage_args_page_fill(wpa, folio, tmp_folio, 0); spin_lock(&fi->lock); tree_insert(&fi->writepages, wpa); @@ -2104,10 +2131,10 @@ 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); return error; @@ -2155,7 +2182,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); @@ -2288,34 +2314,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->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; - data->orig_pages[ap->num_pages] = &folio->page; + fuse_writepage_args_page_fill(wpa, folio, tmp_folio, ap->num_pages); - inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); - inc_node_page_state(&tmp_folio->page, NR_WRITEBACK_TEMP); + data->orig_pages[ap->num_pages] = &folio->page; err = 0; if (data->wpa) { From patchwork Wed Aug 21 23:22:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13772212 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (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 11A5017DFF5 for ; Wed, 21 Aug 2024 23:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282724; cv=none; b=Ae/sZYedeM7Lln5CPr4BcJ5x2Sohy4QV9yg5kyPNl+4SuS+1ng2dsPHN28kGOcrlz15EaG6HMKHi6q6KpBFwSw91kzV7t3xeLvP48FLcCSX97L1GCdiagEW107+IcmHIxsK9ZZNZjHKdNBpLAr55ltTHA4d5ZGDHQr9tLcoN+DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724282724; c=relaxed/simple; bh=lERsL6LkPPQ014nwXvX1HSh1cU8jVK+4wBePK1uTwhg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TqdPX1mHfE8YbYC+wMEmgqtk1wPtSjsCLpJXutz4R4mRM2URYcsVwcWdRDf1imT79MrzxGiDbEhZnT1YYGGBjH0+HS8ETT8uPCOn5E2++kV5Xvis6iJLP1sG4+qC5utQ35YExHdOuQ6bm7owHdtGKF708Hw80gCicU9ItUteHMA= 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=SSqjjf7m; arc=none smtp.client-ip=209.85.128.171 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="SSqjjf7m" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-6bada443ffeso1815807b3.0 for ; Wed, 21 Aug 2024 16:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724282722; x=1724887522; 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=wEFkCyqEoXxF4y5ZXBA9AJG35frZNevBbqzx0TwmkRw=; b=SSqjjf7mDLYhnq1Pgzd5kRG+B4DtEjwMxyq2woMmnjyO78sfHqeNIvB/Z6nuR4Hz7i uRXzerEvoUYZ87cCTow8vT5Jqxs1H/R0EBurY2kEOufmdv6wEP/Q3U1e5v54qa7xMZ9x bmloNgkQowgUOjgCEHpL0mQzJTOlUhbUx1m1gEGlDgf7mQf2ipoFHjoaYOL1U566HH0l 5dPvb3CeUZM1dTN5Cr/biL9g12S9jnZz7GeJ+c2mUsiQtmgRgtt89Yk2QP23InKIJT8F 20VAoT5XRQzYBzKk/uEM4qKJH4UH2FMyQPAynqbdmkC3qvOySqv5dtW9lHehru98zytq kYjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724282722; x=1724887522; 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=wEFkCyqEoXxF4y5ZXBA9AJG35frZNevBbqzx0TwmkRw=; b=fAPgQSoQ25eGi+KpynvfdrPkWyoGUpGFoz2MJfj6TNQaNWGgCK/61NIZSqtkwwZ7ux xExlmvZ3OalphKKVjpUQQOdqKAkHojIclZwaSnbd1H7GXhEaQ07+BIyujvlaQamzRVQm AAn0cvyLyQi4I9KB0wTYpLR5znqgBl2EXSEyCfDvxvrn1VIdiif1wkesDyB5dtZCxF5I Ans74BR8JutE6IJFHc417rM6EXLjw8zTgupzRidK2f8+SBR2VatwGqLrljoIZ9wEzWOG dLb3lemo5P90aX4qjOzQUwDYBxnLh/CctO8tPmpry57rkzudiEazv/x6FYt3UianPAHI 5Yvg== X-Forwarded-Encrypted: i=1; AJvYcCXrKMHuZCqiwvp/nZEh3EG774HmhJAl5nmM1SmlHE5VQawWyfRWdQc4tFHz5cY58nmtbtKIdcWaEYhdhBjt@vger.kernel.org X-Gm-Message-State: AOJu0Ywh+ZTpEuVyxx597g/CYj5yYH/+Bm3ga3Yz/c4uVLqagtxBmUIc sVBv103RZ5KUGa7G2rgSnTHGdWK6e+TWwiRAnMopE0cniSLU1SfJ X-Google-Smtp-Source: AGHT+IEVLHvayz078/bhAZwZskLXMUx/oFfQNWeWxpEJ4LRzpHt8k9etaXVeQabLVYrVM+UFW/sEzw== X-Received: by 2002:a05:690c:2d09:b0:63b:ba95:c8b3 with SMTP id 00721157ae682-6c3040cdf13mr10031507b3.6.1724282721919; Wed, 21 Aug 2024 16:25:21 -0700 (PDT) Received: from localhost (fwdproxy-nha-002.fbsv.net. [2a03:2880:25ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39a7527a4sm389227b3.32.2024.08.21.16.25.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 16:25:21 -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 v2 9/9] fuse: tidy up error paths in fuse_writepages_fill() and fuse_writepage_locked() Date: Wed, 21 Aug 2024 16:22:41 -0700 Message-ID: <20240821232241.3573997-10-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240821232241.3573997-1-joannelkoong@gmail.com> References: <20240821232241.3573997-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Tidy up the error paths in fuse_writepages_fill() and fuse_writepage_locked() to be easier to read / less cluttered. No functional changes added. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index fe8ae19587fb..0a3a92ef645d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2098,16 +2098,19 @@ static int fuse_writepage_locked(struct folio *folio) struct fuse_args_pages *ap; struct folio *tmp_folio; struct fuse_file *ff; - int error = -ENOMEM; + int error; tmp_folio = folio_alloc(GFP_NOFS | __GFP_HIGHMEM, 0); - if (!tmp_folio) + if (!tmp_folio) { + error = -ENOMEM; goto err; + } - error = -EIO; ff = fuse_write_file_get(fi); - if (!ff) + if (!ff) { + error = -EIO; goto err_nofile; + } wpa = fuse_writepage_args_setup(folio, ff); if (!wpa) { @@ -2287,17 +2290,18 @@ static int fuse_writepages_fill(struct folio *folio, struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_conn *fc = get_fuse_conn(inode); struct folio *tmp_folio; - int err; + int err = 0; if (wpa && fuse_writepage_need_send(fc, &folio->page, ap, data)) { fuse_writepages_send(data); data->wpa = NULL; } - err = -ENOMEM; tmp_folio = folio_alloc(GFP_NOFS | __GFP_HIGHMEM, 0); - if (!tmp_folio) + if (!tmp_folio) { + err = -ENOMEM; goto out_unlock; + } /* * The page must not be redirtied until the writeout is completed @@ -2313,10 +2317,10 @@ static int fuse_writepages_fill(struct folio *folio, * under writeback, so we can release the page lock. */ if (data->wpa == NULL) { - err = -ENOMEM; wpa = fuse_writepage_args_setup(folio, data->ff); if (!wpa) { folio_put(tmp_folio); + err = -ENOMEM; goto out_unlock; } fuse_file_get(wpa->ia.ff); @@ -2329,7 +2333,6 @@ static int fuse_writepages_fill(struct folio *folio, data->orig_pages[ap->num_pages] = &folio->page; - err = 0; if (data->wpa) { /* * Protected by fi->lock against concurrent access by