From patchwork Fri Aug 23 16:27:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13775542 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 005FB18BBB4 for ; Fri, 23 Aug 2024 16:27:39 +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=1724430462; cv=none; b=bxJ8f1vEsUnIIbB8UZzTLy4FPOcWhiqvIzZNdrQiN/rRPKSRB3E3sQCBsQwoa/4EpNUd2NdyeEM8hYibDJGYiYAi1WxrwEqEeEOGqzwAix9Lqwq/Mx/+pZyPb0qgxKcYq1e1am5b5rqgKSnyrYMWcp4wp+n1f9byHMlfQbWwCME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430462; c=relaxed/simple; bh=d1sw3RklYepjEi8jrs758o0Ste9SePDfyolWUw0Jdxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rL+3pXKh4uLxT+gyBtch1ZAr95TM7LBVlMy0ug3fYr5clNXThYy1zelWkYdVH5YWh1PtFbgpPHJLjSvHM2qkt54uwW3xxEgDBRyTp4UoTszxUDYmtplMhp6PLjrSc6Ta7Cby63ZEIWHtSDh1vmbXCdmjGxRrB50+m856Zo7jWAs= 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=BP9r+LjB; 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="BP9r+LjB" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-6b44dd520ceso22053117b3.0 for ; Fri, 23 Aug 2024 09:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724430459; x=1725035259; 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=BP9r+LjBjyVHlSc+6B5aL4MLjfFBctnytxVKok9o7OQiUC1OI9HVuWOCuf1owcunia uZB7AQTPLPfZRr9ZSjw4Ez62IvbORcHicu9DHK1SwStvjmdeWL0zl42twndDtQo9CWtW /unz9Rqms0TocuX4zD4S5NU/1yiW0g8t//kvtnryZpX33NA+7FfPxddRWfFbKH+MH9YE EzD868tvplBnG3BXmiWg03WW/aL9bcTvy7Bgzj2W8TMJU7gLDoRMO/w1XlnmbWe1i/FQ vG/On1c6g9KfkrTXrdzO2VUwBVcG3VpklV/QaB4wiJIw47JzcnSkES3JSI0e4wz3WHYm tXjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724430459; x=1725035259; 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=mfjK6tAqFseb5uy4FkaiPUZe09mduk2Y1Rdd97zHPvJmgc9MiUI5TVliEvhUiOWvHO QRFL75m3BivRIyN1ckucptBoOVgXLbh5vis+uSv2d1C9Jyh/2EEo5L5y6mK8gwaOPpge E5YDBjq6N1UoUInX6DQJKEVDSqLLO8oelsrOVIAPG9tWTl0ffCy+HI0L2yGrvUxB+V4P zdKG1mqEiIObr1xTFMxaliuYEcTwvl0pYGhCufmWn++Ahyxknjn2IHWLUldP5ba+UWLS AHmBrnGp3NB5LKFrXlbSeYKKF3XTdJpDAOsaQ1QaYg9m6sHQZxx3CUdGYDho8Wjfiq5e 6R/A== X-Forwarded-Encrypted: i=1; AJvYcCXxGHKZvn6yHt+XUkhd2fBAZ/0NGViSIL/m/mXHyAb/4GXNzRlcPa6fnBT3vbn8ajHkYHWVu/tQOvtfSSQa@vger.kernel.org X-Gm-Message-State: AOJu0Yx+kRAJ28uFdIbO9urAf6p6pOamdAdzaLzzisj7DW/XubETqsLY lgR4AFLTxqC9OYrBzVzOS02rxhKs8eTYOPEcF4CuuLSNqkn1zqx4 X-Google-Smtp-Source: AGHT+IE+sd7E9TfB5HXfBx8aY+Bblz+XZNP6avoo9xtGPYZi9/Ef5L5WjVtGuRpjDdXCnOKPxagOCw== X-Received: by 2002:a05:690c:428c:b0:6b0:12fc:71fb with SMTP id 00721157ae682-6c6258612c6mr25742777b3.18.1724430458945; Fri, 23 Aug 2024 09:27:38 -0700 (PDT) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c399cb5345sm5940667b3.10.2024.08.23.09.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 09:27:38 -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 v3 1/9] fuse: drop unused fuse_mount arg in fuse_writepage_finish() Date: Fri, 23 Aug 2024 09:27:22 -0700 Message-ID: <20240823162730.521499-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240823162730.521499-1-joannelkoong@gmail.com> References: <20240823162730.521499-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 Fri Aug 23 16:27:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13775543 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 72D0B18BB82 for ; Fri, 23 Aug 2024 16:27:41 +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=1724430462; cv=none; b=q5ys9+jfL35znZQZXLyp0yZI2VlCD5L8E1/c53omZincr33UyjSxFy90Ug2F5gqCjpiNFH/lmVE3mKCZRdxoylm4ZBzhEjmFXWNQYtfCGKhmpir/vIKD2m99dJE31D6ir1ZCwIxaRr1tFFI7Qvs80t/0/ay7ZhtXu1OIm9q6RAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430462; c=relaxed/simple; bh=UWKsRqn8KEexlFybvj1D8QiH7e2TeVsMe7AUmeAODaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uPsDF8lM0/4uCR30LlUGc3RPfyki5g08sIWrhPW5IwqjU0Sjf1mMpQ8oS5ONOlbGXa5IOm/WVcphlMsaF03xiWWExLxACvTEqMBIOcOYfOLzTlxOsWGRc8BwtzhKP9iYPWbTBdlrokrKxhM14mmvYzofii0zEr/RR3tZqYNLhV4= 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=HY9oRqvv; 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="HY9oRqvv" Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-e1654a42cb8so2217328276.1 for ; Fri, 23 Aug 2024 09:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724430460; x=1725035260; 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=HY9oRqvvpAJJfQZNISYOf5En9C0sqZ4H0X7mUV10r3JolDqj14rIp/gOEr7UQ3Ydm7 crYnD4ifbxT17IVQnUgBxGsmEkIo+OLGjmjA/Ddm7pKjsjvN1rNqyZRke0M8HnfRRnTq 432I6Q5v2DXENuWSGm9EVnfjqDPeax/wErWgN42r+kygrZ6NcvrBH/Vtd3HbiJvLNY+T /cNCfbRafjwr3sH1P7Vl1YU8M233ENhbmOjwGiLPNwMqDbJPm5UBkDqBsYYQmKPKkzyN rgPH62odbTEDs+z0Vmu8pbAnzgF7A7+AS4Vt3VIEcc53TtvC91XOgGUhHncpCPYaLt8l Tcnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724430460; x=1725035260; 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=iZ15q2/XPv7dITCl5z08cM2nhkDlwZgP7vm8WJaWqztBCxaCkviE22BEqaYeC9AG6q VAZzSA7GDUtVw228rwJ77LQTcxuzF1MapHWBEeMIB5rglfkO7NyuoS7BLyddcjPt9zg2 ojnyplm1oW6rYZ1N3I77GfB86KWxAfrMp/Zrz9VmQjR56onpUIJY8mPE2InFBSTNiOSV oXi8OaaVHdmcFoxBzXJklWk91EpPLQxnucpvWBBA8f6i7mGPAxuu0bHo1hnlYrbkKRcT xoYtXE4TP83lra04hoOfQ3EJMM2mV5mrXi78yVh3hkI/b7wfw2YYqW/3oZ38JTrlimjA eXug== X-Forwarded-Encrypted: i=1; AJvYcCUNfBC++jBErtyNoULoAET6KV9o99+LU2zmVzmw9ca6f1Tou7zbNPvL/huXDu0Q3BW4K2LyEjK11VLH//Rv@vger.kernel.org X-Gm-Message-State: AOJu0YzG5TFaYiKFQKC7ulXnl2zuPNz4/b8Y0/idf8ro06P50jqtjQ9E bfKmIloxo/JOl8XN6glfnWK/SuUAWrIS7xqQpPw02EQJTJuc0pVJ X-Google-Smtp-Source: AGHT+IEm6IPFK5nrK9K8lv7FcaPr2S8CvJgUJE2eCjMIuexI0mgkn5UtELmj5hw8qT45So7/SOdTMg== X-Received: by 2002:a05:6902:1586:b0:e14:85d5:8580 with SMTP id 3f1490d57ef6-e17a864581cmr3422920276.44.1724430460321; Fri, 23 Aug 2024 09:27:40 -0700 (PDT) Received: from localhost (fwdproxy-nha-115.fbsv.net. [2a03:2880:25ff:73::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39dc5327dsm5941247b3.127.2024.08.23.09.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 09:27:40 -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 v3 2/9] fuse: refactor finished writeback stats updates into helper function Date: Fri, 23 Aug 2024 09:27:23 -0700 Message-ID: <20240823162730.521499-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240823162730.521499-1-joannelkoong@gmail.com> References: <20240823162730.521499-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 Fri Aug 23 16:27:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13775544 Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (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 926E318BC02 for ; Fri, 23 Aug 2024 16:27:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430464; cv=none; b=kiqa8c9qV7fuJiNdd0O5Ol7W+/Y4zaKtA/QlE5zZfGzxEhr2POZAvDS9VvPZbgKrF6ne6bmPnVb4rClsMa/i4hAn1ArYnmPcg4kQruhDk2Z5EUVdHy6mDKx8zYixtwU/Cfi5pyXzg9Q0GN1UnRS8/BLqdmbTgJF5QwsRACkmtsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430464; c=relaxed/simple; bh=eaHwMeJ0CTx8L8hGmD/ZgvwlqQiriDj4xMCy/d865M4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ubcye+Z8A2ONy69OQ2iRyJic5SQsumJFLBFzlhpVXtGT0NUlOUi4wmrVKmPJaH8ArrEGpc2fAvbpXnxGGjbQXSL+9qbBAK0lvS93SdXglILP6Jm9FwjQQQxofI3ONRnEhx3GmRtqz65WGYG4uWWP6p79SFMDUDquc5kK2n4RAHw= 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=dJWziSr3; arc=none smtp.client-ip=209.85.219.174 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="dJWziSr3" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e117059666eso2182275276.3 for ; Fri, 23 Aug 2024 09:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724430461; x=1725035261; 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=dJWziSr3XQ53U0zNtIPj/sa7VpvfGRONR8ujxXX2LWpQNs1b5OyOe/ta9vO/rQ598p BDKDTQjYQnMXD4Kd5Ir9zHivgDzcG6jkZ5cT0p4zZIAORPC4iegiKwnaIxpj81logfYK HrRmPN0Q9ySIhzrvJoJ9D6FFcugb65GqCTHHjdJtAM4F22jeI3sAVUEvs78Gau0nNAQ1 ruvMYHfekADHpsaYJjKnJp9bw7bY4qogqutRfTIPW70yNFmcsnXrf+o/XvEpp2egEFXG 1Feq+LdK64Dw3s8mwrP7Hcr1HkjUBix6BGEsQbldQuko28NTA9ynWQnXuxAXgexuAkfg D7jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724430461; x=1725035261; 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=CPpq34EZKUUS9Y1p5nQ3gEBC2FtCA2Phq7faUAwK6Di9ac6JNxQ+yl5A2LNtlfgLCu D+cv5Iqo8CRFBru6enBkdd9ibB1tohq3WvK7BHz+0LQJsNNiXIqOWG63p9sOUr60nVub FO0PsJwEghkrxFVxhOZ1ErvA1xSwmqRrtRjJXi8Hq6CAQFYt13jZKA+KH1kG2w0pdlwY LlKbCiBQPQIoN2khM6p7gpHScNf4F1fgwPG5C00T/4w+sG8D4MxoufETDCkUEK8EYPah c94zxngZgIdoRnwpFcn4B+oyFhWszHirlHdYqb0VmeccqQchLTpQhlQuWnhRqCtfsau8 hVTg== X-Forwarded-Encrypted: i=1; AJvYcCWmY7yVA19QwPBy9GaPKibLABwO+Ji53BJ+m/Vt1tsH7oMY/i7de51RHoHD04hlg5yb6+mBRkwuLAhIFWrE@vger.kernel.org X-Gm-Message-State: AOJu0YzGlGiC+9Mk6aXfEQjzKe69XDmOTI3zWq6RBzIeufbSfbPrVBHb eaUvMBjuUMGVOOIWAzRAJdUSCrgp1j5Yo3m81+G9E9w46rNp2DpS X-Google-Smtp-Source: AGHT+IF91VYXjuhUg8ewE14V0S1G38gggm/K10gjMxFKcOA5ipwIAVaqEHPcUcoQWDJOYrE4klCPmg== X-Received: by 2002:a05:6902:1603:b0:e11:6c6d:8c1a with SMTP id 3f1490d57ef6-e17a83bc673mr4217461276.8.1724430461366; Fri, 23 Aug 2024 09:27:41 -0700 (PDT) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e178e4bc94asm740133276.39.2024.08.23.09.27.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 09:27:41 -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 v3 3/9] fuse: update stats for pages in dropped aux writeback list Date: Fri, 23 Aug 2024 09:27:24 -0700 Message-ID: <20240823162730.521499-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240823162730.521499-1-joannelkoong@gmail.com> References: <20240823162730.521499-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 Fri Aug 23 16:27:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13775545 Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.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 9627118BC10 for ; Fri, 23 Aug 2024 16:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430465; cv=none; b=dT7R0t8+OtmCDiKoYR0ur5ncgG67MCQCyd64r43bxAoSWBnodPTRIsWRBht87yJZgcmeBzYqaVI1mW+ldFZVL3Imm+v1X9mrCQvlJ1I4fMQTRocdbyfbaY9x7HKGwR2z+YaIi+0kWdnOnQ0iK1lI8DGZBSc1dQu/68hzRMCXGFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430465; c=relaxed/simple; bh=s2ckAHicpl/to3zXFLNJePIx3hN+gTnQ2xFFhBBYmXM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RC9EJOuF12Ww+kWfzelLF9aKhQRsZc2d3qywLIc9jPDuEN9I6C2AuIDGs0p3jiWbMNd6NogThe3yC1esR+caZtTD2/JMcrYwgj+z3URqAMV6zsy+SKxX7vkIMuQhVpMQwMO/2kH9Ks9jxuOoc8c2mGzCvBSxmGdatRwm9jqpjmw= 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=Cy2dsEz2; arc=none smtp.client-ip=209.85.219.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="Cy2dsEz2" Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-e1659e9a982so2471693276.1 for ; Fri, 23 Aug 2024 09:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724430462; x=1725035262; 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=Cy2dsEz2NKD34vnwgqsOkyHAhl4Tcc8VgnUNA2cHIdUPUB6f31rvXHMIxVeOEV3djR Zy38ZSe1C3lwrp6XO/RVtvoqknFuRB8H9jphdhYYeHBQnTrxvv/hVPzNCbZ3CF0CusLJ PrvZpAb0hvbHvZFMdnYHBFH50ZT/J0iBSnqAfNy8Fp2YqIuLtqYEJKFqFXqyTfxWLPfN qqFKeWhp/Q/rTv9M360Cj9aFGuneCzVY4oIYBrPKCrTo6OuMst65LuTq4A98fyzBkzu4 zp2TqmW5QZM1nEvV3t1Etg/6lL2hFKrx62lT5giFot0rhIL0Xofba99DHaUWbjxCJqLx Lctg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724430462; x=1725035262; 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=Ct/4TE//nTwOHdWVCmPNvAy36nal4ZMOuIcO9A6u7xuxzBSl0tzVogGSe443nhwqp1 qNFBP3i2FnQLXV1E83eCcUO3CWek6fpqIzONoqmQ8flAhRIEdfwf7p127Np003BbBLvj fm4W3lvA5z1ZebUktnbmcbgVPaX5kUywrbdo5r7rWVZRuB6PQIX8LxhaLuUXPMPo7+8c VEhY2DsFU5MASQ/Cc8XWGxLax3e2TBjLlBOFZRBsGSjac7SZ1Sp4I8SxE9UMJnRSly+p jVTRuEUgh5MOO50PPE2m6iShozjvsgTwzM46enCOBMxNuyVUlKdrvJgZokNoHG4JMqRH 7VRw== X-Forwarded-Encrypted: i=1; AJvYcCXm2Xw4b6wNewwPQfEcExKM0mJm9jJkKQioZmBRE6m1ZvTOKjEn3KOPgAQKMVJ/2x/q8B93rBi3ysuU+cWu@vger.kernel.org X-Gm-Message-State: AOJu0Yytp6I/tml5YfyFUr8VGiE8mWUhdo5Ui2fZm7yQMy8Ol9EVeR16 n3JOagV2RpBvLgX6dOOzZx5W/7chMVgUga3qbCe+lLJ7Hc6wggtQ X-Google-Smtp-Source: AGHT+IHcIZuM7nffEiX6saPg44AymkHorWl73Ly5LOppl9Fqqnd3BBc0dOHW7TVTj5Nt2NesgDxEPQ== X-Received: by 2002:a05:6902:200e:b0:e0b:cac5:63bb with SMTP id 3f1490d57ef6-e17a86665d6mr2810326276.46.1724430462509; Fri, 23 Aug 2024 09:27:42 -0700 (PDT) Received: from localhost (fwdproxy-nha-004.fbsv.net. [2a03:2880:25ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e178e4b73f2sm712335276.33.2024.08.23.09.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 09:27:42 -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 v3 4/9] fuse: clean up error handling in fuse_writepages() Date: Fri, 23 Aug 2024 09:27:25 -0700 Message-ID: <20240823162730.521499-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240823162730.521499-1-joannelkoong@gmail.com> References: <20240823162730.521499-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 Fri Aug 23 16:27:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13775546 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 AEEF318BC2C for ; Fri, 23 Aug 2024 16:27:44 +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=1724430466; cv=none; b=ko1W+t+OoNqW3k60ozRH0Mgn0chvWEcTJ6kNZuviJbAL4dy3kGfjM0+Yv3A8IT4cZWMD4AdOPkgwB4taqXMRY5ICjxz+wwMNB84cKbGeHEGgGk2UlYp5Ymf/ffUfavXEg9BXhZyJ31KuIMkmW4ZBiIoLt0B9S0ogdPXrfQGYIFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430466; c=relaxed/simple; bh=2hl7CHEMpJthJ2Gv/rGTxI8M0xUZep1a2SROzXYq36Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M/Ko+2aLTTJKSxxwQTR5lPouXbYeeaRNsPfyjyFp4fcxIA3vLBI0I2G/5Gboahv1BFIGEf7QwG5E2/lOZd4VtlfOKCAiyW4EgsaGpmvJ4kQzbGzuWardhKq2WVQansB3E85Z0SnNoK9ROyWm0DfwZRNMO76f/SvrnuWgEaL1t90= 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=DWNvzrwq; 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="DWNvzrwq" Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e13cce6dc85so2196781276.2 for ; Fri, 23 Aug 2024 09:27:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724430464; x=1725035264; 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=SnBL8Jku7P0e8a6SKmjqla9DRPRM4ac6C8nHST2s0DI=; b=DWNvzrwqN+8U5QAX3ACBlFIubNOS7FBUKJIQ1Vf9ad8zxjrfdTeV4+6xL5SPchn+dG L25wIDX88qRIV2HqPEw4a+R/FLyALTtN7Ai1rGbZYHegjOnlm60ozE2LDiN+4baUjVux nIrLKWksAX2SF79Rrm+s7hmjGjy11GkV1+xDOPnT25K6eMkRA3dgn1ulp7qqys6LGvTK yK6MPvvobH0JX1mEnusD6LFMLxUThuXK20xi6SiOwA0ZQZipfTUnO9bwap5HQq+/qyQu 6ogsHKlgp/hqUvSYLOxocQHOImelmxr2G0V4g7ORfQT524mWvUlbN7PCeE9eWeqn7dcu rTPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724430464; x=1725035264; 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=SnBL8Jku7P0e8a6SKmjqla9DRPRM4ac6C8nHST2s0DI=; b=F0zUdbWqBZ+rD+kpbmn0JkagkVGNQyTsZX1nFvyBJAMhpcV3HMMfJ/beRVo1RWwQuf 2UpBNALqzenr55dpjZKbqL/zEee0sEJXDgSFcUYIrWJ6aYtMV2EtjA3btpIlXtjCIuxB c4acTX30Io9GEKqEixF0J4a73NGdDtiMwaq1k+tvGQ7/4HtOdRwAwsiBpuJMMkn+Gexs +4lJW85i0cOIZOfVgoOswSbpfdSa5tSXF4V4eEX/UOHE2+6HTrOSIvBjnT7I2AZihMfs l7Bly60Yw+1RvgJCL2iQLDKObYRCzHb/jLrwfUBVadi9OQhgP27JsTM6J5wutcwYBC5C fY1A== X-Forwarded-Encrypted: i=1; AJvYcCVzx/iybwV6OxcKHL81PFq5ONTAOtQsafcYj8chQOaZpiVa5rjlOBWS+3J0ciZfqjv+rV7pyj+gKTrtaTJv@vger.kernel.org X-Gm-Message-State: AOJu0Yx7BFEL1nuDI8SWF+4rx/eJySnuEPRKew7qO4TTcWJDwNL0lOW+ QiYj1PkEOv1tMFFAgU2gG3gK68SDMA7KsqDxNXyZLekJGU3BJzMw X-Google-Smtp-Source: AGHT+IHJH2XLTpUohMXuQqmUTWAKU8wYYmIoz+Fo+A5raRnZ12ua2TS7XHr6e/mVKh9EWNmV7sA0GQ== X-Received: by 2002:a05:690c:ed5:b0:6ad:75f6:679f with SMTP id 00721157ae682-6c6251a3c1bmr32712627b3.6.1724430463638; Fri, 23 Aug 2024 09:27:43 -0700 (PDT) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b007fbesm5983697b3.70.2024.08.23.09.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 09:27:43 -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 v3 5/9] fuse: move initialization of fuse_file to fuse_writepages() instead of in callback Date: Fri, 23 Aug 2024 09:27:26 -0700 Message-ID: <20240823162730.521499-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240823162730.521499-1-joannelkoong@gmail.com> References: <20240823162730.521499-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 | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 8a9b6e8dbd1b..a51b0b085616 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,23 +2355,26 @@ 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); + err = -ENOMEM; if (!data.orig_pages) - return -ENOMEM; + goto out; 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); kfree(data.orig_pages); +out: + fuse_file_put(data.ff, false); return err; } From patchwork Fri Aug 23 16:27:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13775547 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 97B5C18DF81 for ; Fri, 23 Aug 2024 16:27:45 +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=1724430467; cv=none; b=pjTbKxrk2rmhLV/SBzhM/myTyv94WU0mCRlhtaVuMwkKqdkT6v5752By6x14+C2BnrgQE+wmbONSVLziEcScaOT/8bvcieVcqdrgI2i/mPWcdUzL/FvgjL3rg+Nlt3s4AeFu4A6ozgtVnmC4znsW81ZJkbDj7n09cns7w7RkavQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430467; c=relaxed/simple; bh=BCWLaokALe3n0fYU9hV7T1e4BPVGraqKKewR6GbmZEw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=flBpKmHrJC9cveE3ewN3Gzq8TsNKjthp2RpjQbIYeGtmj5P6nARUsfU/YoXOh8V1dW++anDXx4pYjHJLf5uLlNyzdb4/laFS25BrZL1plsI8gAt9eIyO/HsOSXF+oUeik2e0O3orUJouLe19QGzk53Bb73nFOwSGxQUkBSb4M8o= 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=VNF1cNgD; 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="VNF1cNgD" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-690e9001e01so20669727b3.3 for ; Fri, 23 Aug 2024 09:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724430464; x=1725035264; 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=tK5FE5FzMMbXdXMgVp7PugykD5NwuMLOFm247vIYHks=; b=VNF1cNgD0fpHj+Ie70uHRFl67PweN7qC/krcrHEx5IK1KOrsvz7ldTIWRcwzTyoILw mirA1i9EkrmLRT0G1qYyU6r5t49czRL3s9ilJbQWrL4oRmlH+O6HllOg4In7VQ8ckmmT QSwWJoA8nb6Fpn8Zs9cQhuyY86i+laByLVgobD4VWMrCelclb8+VQxsL9H1LL47NGfZA qNDUMQeJMKUum4UKaqm1N4Z+Hob3sdw1ok+ID6PJplNiYg7y5CreN7wgLRr7jz/TNrVI cP8jQ7wnErArKwFIWZaA0mBU9gJR1+W7cteyaQnJfrzABmagN7ZbS6UMyOFhRYzkknBg axkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724430464; x=1725035264; 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=tK5FE5FzMMbXdXMgVp7PugykD5NwuMLOFm247vIYHks=; b=IFlMWXXki5mCoO94ZxnTfDaRRvBGEyLjTNbYgcZ6sa8HA+qPP4pp+d1ZoUCg0pPtHf 6rCLQz5XUHEPgKJxSNYC4UwvhhgfaHg/IvAe56f4Z/YWNnVoA5eDBscMm7oKE+ov9dn+ 0T0jve8gBwiyUdT/YMhwRd7SkOeYKDs/kHUzXkA1733x6AFV4S8VtzQlys3P1ezmGCK+ Ro4eMja/vqjywB8kDmAWcmAvK06qx8Bg0gfS4EqOJplxacfrRjMp6e9W4yR7C4m8faMo kxUdto9LH/mg2IDiMTFX3YCjzjMA6jljhr2gYnl7p5fSv2zFCmdZWxPKRfBz6i7Q2nGD +srQ== X-Forwarded-Encrypted: i=1; AJvYcCV+1cq2ju4XfKr43cWmQ8curaOo2QHXhzYM7uKx3cSa1OpT8e9caA/27yV2WAbt3QN0yxjUokPhUg0lfUkV@vger.kernel.org X-Gm-Message-State: AOJu0Yz+gFrXQ65JdpfosSk4Hczq8m+vLk5Uy+8U39psYogbVhKAWC7N /jUBZJ/Z8453oP47veHST1BDhqbOUhcTrAw5K6GgqI/cd0hPwtKx X-Google-Smtp-Source: AGHT+IGz9DrHln8n6qHcuIfMa2t6x5H/LbEqkdj7XHRQrPzK5I3EqxLujVA8ryJ4TkjyT6weJC9L0A== X-Received: by 2002:a05:690c:5888:b0:6bd:7eb:7192 with SMTP id 00721157ae682-6c6268bcd4bmr22304137b3.25.1724430464600; Fri, 23 Aug 2024 09:27:44 -0700 (PDT) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b007afcsm5938457b3.72.2024.08.23.09.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 09:27:44 -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 v3 6/9] fuse: convert fuse_writepages_fill() to use a folio for its tmp page Date: Fri, 23 Aug 2024 09:27:27 -0700 Message-ID: <20240823162730.521499-7-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240823162730.521499-1-joannelkoong@gmail.com> References: <20240823162730.521499-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 a51b0b085616..905b202a7acd 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 Fri Aug 23 16:27:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13775548 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (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 9454918E022 for ; Fri, 23 Aug 2024 16:27:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430468; cv=none; b=tASkmpUY3w862DW6c3x8V6YLq99YPHpdNWRawmDihH2YbDjFB0XUX42UuOfQEg2P4knVCQiKiBEgWsnEdZen8X8/L14wjQNv7ZHkwWF1JIC1BxY/8LFIQbafiRrzZDW0OPJHrfgmAxBm0i5kYJOhEjdXA6NzSgSZmyxgYiW0QD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430468; c=relaxed/simple; bh=Fr310KpdfEiwRi78xJDDOcgs0wlrFL4uDgrebaR3HTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z13RmHbXMGNamvN4F9hZKh4dPaqYCTf4Vin79hLYe9t32K5S8aBOHtypBlAVcejvtkhXdEvZkUCAjvZ/UAhBTZBtHh2QsiyUUtZxINX6jTgmNqohskerLjcUf+UCzAcspmgsyZhkf7cj6RiAH+LGk1W7YGwLuOcGLgve3n7KwJs= 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=aQID47pu; arc=none smtp.client-ip=209.85.128.182 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="aQID47pu" Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-6b747f2e2b7so20584047b3.3 for ; Fri, 23 Aug 2024 09:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724430465; x=1725035265; 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=dXRc53IcYY7VACycZ4VyUa0QB5NcTdDD31/jr4+UwJg=; b=aQID47puekQrm4E/c2kRUAK/Zbbs1FM3JPRc6n7yfcd5HrU7U0p1m5USNG/dag++xB DnpxBtZ+Ue69tjEcLrMYrHkQv7NQ4LB13NYxEx6GOmII40eeSCGzv9RDeQtg83MQ+Bl1 TsIvSQ9E/TdAt+/+p57t0sm7M3D6sPSHXkzDLxZT8a3W4qmvPPxMk1P3fpk5u7ngg7d3 bFb/ilkD5zfg0VttzlQip6OutgDkLyGVE2u6zTkcTPzhSd3dSl2BAxVR2b59N19WiQAd M+lMQdw4AlWIYnLrae6+/oztu0CyD9ChEnYTEWPfVYsS6zzKylb25QGOzdKBqaZn79S/ z8pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724430465; x=1725035265; 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=dXRc53IcYY7VACycZ4VyUa0QB5NcTdDD31/jr4+UwJg=; b=DDYJUuJDaNizz6cfYa50hxuSjKVoXrtyb3eeDPdPHK1/OO+7Opu3wvdKaBjNv0mqQM AHbzfoeSKL0ZL9FKJcsF85kbmioxS94a0H65OOomF/OsXMzih5mhxIKh58zjYDSJcW7g Q543YXOTA15ALfYlDZ9bYf23lcu/jwWMwvAlT+DcslNgrvFGLmO5VTXFAsiLV776sW1w hhI8GBsCIYvwnp0X3R2rgTvSHQaCT4dDepF2C5vrTEguvLRL+uUT1rwr8YaWtVbOmo4N I0jp3rZ9S8wArHXpxLv1axU2uGZ6hU7katHZTMGyGNMOXbrPHi7dbHZrWT/5yXl0F+lX XylQ== X-Forwarded-Encrypted: i=1; AJvYcCWcesgsiGrd0ZUgDocq4ovB8YxZM3ipCmdQFl6Ngw2Cx2/R0g9EAigtlJVGKZ55s3UDwFJjukjKs2IGKYrz@vger.kernel.org X-Gm-Message-State: AOJu0YxbIUSZdmrKEsPru3oRvbktK8zys7JupoYjrPiUHHGkz+ZdHEEn s79bg499KneMJCGi4UcfrTLr1rFF5qjb+0uaBu33VfUxipRVSmZ1Df9NEA== X-Google-Smtp-Source: AGHT+IG+IYMOOv1hRsXsrbFY0Sb9vTejv1Bhi7btumeWDIcT8NhMW6tSTVMI8MHJh9Pa0GOCD5htFg== X-Received: by 2002:a05:690c:fce:b0:6ad:ac4f:a1a6 with SMTP id 00721157ae682-6c624bd7e28mr32258737b3.12.1724430465609; Fri, 23 Aug 2024 09:27:45 -0700 (PDT) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c399cb4e6dsm5967037b3.9.2024.08.23.09.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 09:27:45 -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 v3 7/9] fuse: move folio_start_writeback to after the allocations in fuse_writepage_locked() Date: Fri, 23 Aug 2024 09:27:28 -0700 Message-ID: <20240823162730.521499-8-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240823162730.521499-1-joannelkoong@gmail.com> References: <20240823162730.521499-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 905b202a7acd..3d84cbb1a2d9 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 Fri Aug 23 16:27:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13775549 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (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 B133418E35F for ; Fri, 23 Aug 2024 16:27:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430470; cv=none; b=JIpqjniuK9C24Abcu+8ER6JwENtZRET5Cf7VRxvRUyRfOiYwajWsWqBjNpVTrHt9YUeHk29c7e1BZXKJINl0HyYOuOBYJA4hDPFr3xJxwvkDXMl3xfi3WONJh83PvFZMNQlem2zEMt8hN9cxdLqPZvAw6B0GZhYxEonFnzllkHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430470; c=relaxed/simple; bh=82eYQz6sfyzy/Ia5s7CuFQJu0fKMz2l5LMKTvCenvhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MaBkd8je3WIil50YUu3qbmw/vZwBdUG6vTSl/IqMi+7qjGhCmV1AJiyA7RiA7QPM74XDwq4DgCjFPuVZ8/DVMazBeAV9JRsriUu0hgZS+qOvKYSB99B1xIztGwQAU3SCBf2frQTqweQ8riruJAQIQ46Qc2fiun/agyWmxj5YvTw= 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=UNn2Hq9B; arc=none smtp.client-ip=209.85.128.182 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="UNn2Hq9B" Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-6b99988b6ceso23441467b3.0 for ; Fri, 23 Aug 2024 09:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724430468; x=1725035268; 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=RPPFzN7yYaPQyq6TUhQbGJPQE9oLj4GQdoaKu6JHvz8=; b=UNn2Hq9BcQ6meO8+uSanvaUbN8fhMSgTjV1hWo0wDM8yBuEZUnmwSoDwSQlYb5RQsq D9AmPpWfuLz8WMcP0mD8f0eH0LfOeqZT/xblJFL37OnhmM0IFR5dPE0/esu77u9qolKD 48tNtqlqOIQSYngD6x9LyweTlB1WdpFK9hq869JKYSSC6HM8ZtcOp60R+tAQBaBpP7cR F8qTf+yCS+5Ez0fVt0YNVwOuLM2VNwWEucMx0lpaohS95+5+TYro9soTeuhTaOjELVKJ ejvtzlAcVTRowclllS7LZmAlSDhuR8hQ94+4GWHm5bopQfwRgGPwT3VW0YL5+n9zhIQj +KMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724430468; x=1725035268; 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=RPPFzN7yYaPQyq6TUhQbGJPQE9oLj4GQdoaKu6JHvz8=; b=HlnnX1yLark48UBbRtAez1tD/DBgRihWidiNBYSQ3AHSEA3ZHqAwOGrB/yUPR0+gLg Gup5AURaOdwlezbinJL5spYjQyRlS5q02+88aV6m1N8fYvtjuv9LU3XeuxB4jAeIvgPV y3lv1oOGvT24GelbCSOyglYEydK5pwFJM9+sqpjCrZ/pkO1ah1LbEpea10EB0YKmWivC O3AnuRPO19XLAAshCH1flC9KPTZoGqqySsH5HeJSnHZ+SI6meK7+N0oP+ONA4ytoWYs+ PjhN1UT82AxNRR7QCSqLVRyRFmBQNW//VhIlFJDiicPs9l6TwoCp2Sb0YJe3pnD1M5Gp 0feA== X-Forwarded-Encrypted: i=1; AJvYcCXS1DwZzGscNcwDmSyYzJtjS1I5i0CBUN8kiJADU5C18IN2f+evFMf5e76cncp4w2Y/pBqFPt7lL8Ip9YZ2@vger.kernel.org X-Gm-Message-State: AOJu0Yx03AzLXlf90i/UOFsOSopdZTohKHfcUVP8oi7SDCOkOHndH9GO Pt8jj79I/mynFy9FRno5YU8Gsbcb209BGbJc5NNIZx66QMvkM8VU X-Google-Smtp-Source: AGHT+IETIeMkCLjHGvZrv2SPjsTSeQvY2a9vf5E7YJ6a5bqCKnarAi6jF1vPhPJklznZ72s5wKrF3A== X-Received: by 2002:a05:690c:3806:b0:6a9:4fdd:94e5 with SMTP id 00721157ae682-6c62557b877mr35733757b3.13.1724430467720; Fri, 23 Aug 2024 09:27:47 -0700 (PDT) Received: from localhost (fwdproxy-nha-003.fbsv.net. [2a03:2880:25ff:3::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c399cb4f82sm5997117b3.1.2024.08.23.09.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 09:27:47 -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 v3 8/9] fuse: move fuse file initialization to wpa allocation time Date: Fri, 23 Aug 2024 09:27:29 -0700 Message-ID: <20240823162730.521499-9-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240823162730.521499-1-joannelkoong@gmail.com> References: <20240823162730.521499-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 3d84cbb1a2d9..2348baf2521c 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 Fri Aug 23 16:27:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13775550 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.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 24BFE18B49C for ; Fri, 23 Aug 2024 16:27:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430471; cv=none; b=TFra9wSYWrf3EcRB/LiuuRfkP0rlCFyWkX2YnPRY/IPzXKKz+cvMQ/MIpsroOEHU/mQ65fKfoHxMxsX7Tqwu6mYtonYCt7a8bVwUb23uddJm305QF2kr6d+w9AHTLZSwDvQ21tJDz6Yu7QEIbaiWGDG8AGGfXaLyGtbPBzsby1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724430471; c=relaxed/simple; bh=eb/8qpiT7j/DhU8t5pSUawoZtru9OVDFDwQx8cVOuv0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=et1r9U7+qP0arCdQoz9htOuZAXPI66viEXTQB8xJd/PpLex82m/UelPMZY4zDmDDQvJfKmx9WocZ34t6tD90uxoven3TOKe+l2s01STzdcRANMTT2ehDujeSb//Z76psBt50BcEG5tXNKz2Ndpo2pM9sDwqrSJFkXurQCtZVBrc= 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=XQGF0+Aa; arc=none smtp.client-ip=209.85.128.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="XQGF0+Aa" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-6b44dd520ceso22054847b3.0 for ; Fri, 23 Aug 2024 09:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724430469; x=1725035269; 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=I217fz16cOnt5oEHhpWUdlzv47nxJBvXhKdCBirV+no=; b=XQGF0+Aa3DjYQT0PJpcrvKxIQG4J+ffWY2t4dHyP96jgwpO5Nq3H8GTkLf3zFaKaLa MMnut8s2AzXukjEHJAQrLzC9G57q7U+14EYzvJJRab4nSuu7InclYeqThBqXqvGv1qbx czuvQqty/kAcfilyvPVm32S64qlsgmAT3Afd3gp1IESwaYj3aCduQz8F0o+30yx9GpUv 4rHr8K0WvP2z+S8U3hkZmNzmBWRnqaaxqXfQXFebysxd3kDeoqr4ZjuFYYJan//e2OaY CLow5dZ+VmDr1QTs5CewFHhtmP61faQINcG3ZMCFk7ki0/p1kLw+71Xz03moHIX36tS/ zMsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724430469; x=1725035269; 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=I217fz16cOnt5oEHhpWUdlzv47nxJBvXhKdCBirV+no=; b=sY3YSbeisVoxphG+GGcyGR+xIaS62wbI7PavvW4vvPNAy1n5Hu9WdoF+ZJfUDd7sF6 AB136WA+7WHnwizcBEzXIcplvbD+5KG3P3pGrE3wNl9dcKu6z0ajYeGJUOs9noceEY3e YPsJOKT7wm6+yINbTKWLz983A5LaqjUcUk1znyvmdTuZ5bKEb9golji/h8mlWSHOYOR7 2kQTQ0KmjOlMy+ATJ45DnTRQ0ILpjGqnRa3xTU3WyIqJ/TaD3rTpxqyiSOZxqqGHL6Od Pp1nfK9VL0PWDX42tDSyVqNUIGh0femOB5Fg2xIAKgjk2eE2ZjhBbIzWUHPy3wowODq/ VlEw== X-Forwarded-Encrypted: i=1; AJvYcCU+5HROn64w97C7utwfJag8JBM0/efMObfqyKz1KJnQCXUmnXID1oTP4urW7WiiCG2cWTk207HWYu+dR46h@vger.kernel.org X-Gm-Message-State: AOJu0YxjUjzG1FIU6aNljlx+z8tAUdDA9TozzE2PZRPaTjbZEu6iMuUE uq2Zyc1EXipGEUbecJRmniUxWjpYMKc42NGgRa1Eu2cEe5LEJnjMCvzVpA== X-Google-Smtp-Source: AGHT+IHhdaKfwtyUoIAJINT1DlUaufdaxfmwinGtrbSzZz1cpKfww319rOg9jI+lBGcXMsW+F4j82A== X-Received: by 2002:a05:690c:3303:b0:6b7:f467:e09d with SMTP id 00721157ae682-6c625a4c8d4mr26187577b3.22.1724430469156; Fri, 23 Aug 2024 09:27:49 -0700 (PDT) Received: from localhost (fwdproxy-nha-009.fbsv.net. [2a03:2880:25ff:9::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b006490sm5970097b3.63.2024.08.23.09.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 09:27:48 -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 v3 9/9] fuse: refactor out shared logic in fuse_writepages_fill() and fuse_writepage_locked() Date: Fri, 23 Aug 2024 09:27:30 -0700 Message-ID: <20240823162730.521499-10-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240823162730.521499-1-joannelkoong@gmail.com> References: <20240823162730.521499-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 | 99 ++++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 2348baf2521c..88f872c02349 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2047,50 +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; - 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); + error = -ENOMEM; + if (!wpa) + 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); @@ -2102,10 +2129,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; @@ -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) { /*