From patchwork Fri Jul 26 19:35:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743069 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 87ADC433B9 for ; Fri, 26 Jul 2024 19:36:39 +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=1722022601; cv=none; b=HydB41W+av7ddJeYmyxkhInmXM5M+fxvA3/C/Hiwo7q0X0j47kIo+TKSXHcUZFRasGbC+cz2R3w0Xl+PzFrWCigNJGlRE+NS+nOpKy50DpExAU7GzWwIouQGBkluoJV1bn2lFb0zfT4cayJoWP4nk5IAEXZX+bhRErY5lUh+QuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022601; c=relaxed/simple; bh=xyi88THPFX2gWr+re7GLpuJAPdkz/QaVjqnB+A6McAw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZjOlxz0K8HuDXv8pwuBkKliyiTmPyPvBpy/jLkqZA105TiLX/f/icESTxBlI1Sd/+QEDgyWVllwop6qfhEi9+tUXQwWnEr7rQvDheBcXjuLA310ScOPpdyjhXvhlbSD5NfmfJp8J75VjY2nL5xkGfG7NXEGP0viGlwMghYTj+Wo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=Mghzl9Io; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="Mghzl9Io" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-664ccd158b0so356687b3.1 for ; Fri, 26 Jul 2024 12:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022598; x=1722627398; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=RS0TTQT2jStvTHFxGnRtX4MrtHswBW12/WYDHf9I5sQ=; b=Mghzl9Io08MENhWPLaWl64HR97lcJdOjWb7t/00V+lfkLci/oTiz44Qu8VxSLTCVUg davSfAQODBGIPLhP3h+KS5GQR1s3CsJvvkD6yD319daAG4iGd27EXYl4JFqJVN3fcpvE h3ia0Q/cct7t0FXSXQ7s1SKjAOpBJc4iwsjj3ViwiuD2MsZLga+yCIi2Dy/YOq8CIgmA Fx7xNrLGf3Me4MwaJTgL2s2AY/J9WgO1NjZZjSeRcc0BnDTfZZS84/HlDhZG2sheEAWx 256TfkLiq/P6uBf2MA83dtwqzkpgWqLkrxy2ZXqaYWxVT6BGswyp0HBjmD6FNDGjq8ps Ol5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022598; x=1722627398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RS0TTQT2jStvTHFxGnRtX4MrtHswBW12/WYDHf9I5sQ=; b=w7LpSTmKjrFg75FdTdFHBp4YF23N3IX2VusLriaQxxkSk07/+Cewtp13VQF+OQCcod KZnD5gDWmQGMEiEk6fnrwPh06KaeVi3n3g1hz9z+n4wT4XBm0rBEFNBv+eTjOWvyazHj SATfYdDTZFlau5xahh0D95MrMjjti74TuXBBRrzeNCuwhvYAgQQuxrAPYh2ioATiPSz8 Pv2ihw+PQMM4qvXOpEkY3b+7QESiSUPxiMJ9rSWRttwHlyH2uvcdFklTX1sJUX1fiG4U VeiPK59EdJDmxuyrthMpVMYIWutfr29GPaX5VK07ZiqxZBfimsnk8wzITCf4eQu28A5y Lhnw== X-Gm-Message-State: AOJu0YxmnwtMARMSbfBjNTcUoaxoQCBx2anQYL2LKS7PGINlQn8yJFjs tM6IpA8O+4eviOWjpW1E5vdUkQ5Yzk6oqLP0RD41qYGtA/lj0oEvSchWoz4Di33zYJ7FahoAcew 9 X-Google-Smtp-Source: AGHT+IFjEWGZAukGYNMB6pDAB87OWI1Zi4A1qtjOMPwIEq4+Z4i93Zq2O2YOAZQ0VOCu2NgfcRrN/A== X-Received: by 2002:a0d:ee42:0:b0:643:aef1:fb9d with SMTP id 00721157ae682-67a053e118cmr10055257b3.4.1722022598157; Fri, 26 Jul 2024 12:36:38 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756795e7desm10014517b3.47.2024.07.26.12.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:37 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 01/46] btrfs: convert btrfs_readahead to only use folio Date: Fri, 26 Jul 2024 15:35:48 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We're the only user of readahead_page_batch(). Convert btrfs_readahead to use the folio based helpers to do readahead. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index aa7f8148cd0d..a4d5f8d00f04 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1176,26 +1176,6 @@ int btrfs_read_folio(struct file *file, struct folio *folio) return ret; } -static inline void contiguous_readpages(struct page *pages[], int nr_pages, - u64 start, u64 end, - struct extent_map **em_cached, - struct btrfs_bio_ctrl *bio_ctrl, - u64 *prev_em_start) -{ - struct btrfs_inode *inode = page_to_inode(pages[0]); - int index; - - ASSERT(em_cached); - - btrfs_lock_and_flush_ordered_range(inode, start, end, NULL); - - for (index = 0; index < nr_pages; index++) { - btrfs_do_readpage(pages[index], em_cached, bio_ctrl, - prev_em_start); - put_page(pages[index]); - } -} - /* * helper for __extent_writepage, doing all of the delayed allocation setup. * @@ -2379,18 +2359,18 @@ int btrfs_writepages(struct address_space *mapping, struct writeback_control *wb void btrfs_readahead(struct readahead_control *rac) { struct btrfs_bio_ctrl bio_ctrl = { .opf = REQ_OP_READ | REQ_RAHEAD }; - struct page *pagepool[16]; + struct btrfs_inode *inode = BTRFS_I(rac->mapping->host); + struct folio *folio; + u64 start = readahead_pos(rac); + u64 end = start + readahead_length(rac) - 1; struct extent_map *em_cached = NULL; u64 prev_em_start = (u64)-1; - int nr; - while ((nr = readahead_page_batch(rac, pagepool))) { - u64 contig_start = readahead_pos(rac); - u64 contig_end = contig_start + readahead_batch_length(rac) - 1; + btrfs_lock_and_flush_ordered_range(inode, start, end, NULL); - contiguous_readpages(pagepool, nr, contig_start, contig_end, - &em_cached, &bio_ctrl, &prev_em_start); - } + while ((folio = readahead_folio(rac)) != NULL) + btrfs_do_readpage(&folio->page, &em_cached, &bio_ctrl, + &prev_em_start); if (em_cached) free_extent_map(em_cached); From patchwork Fri Jul 26 19:35:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743070 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.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 4FF464963A for ; Fri, 26 Jul 2024 19:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022601; cv=none; b=A6fvzt+zcOFMvcW72knvdgNmrh3xZhlzfAxgVh7YRlzUaWI+n4WHEvbwrxH6FX3hLCnfL0I5UVcBGrZf6r4PkwBHFlrTUrFaqYsZ7ofIid2LpVBLAQVWNFhkhVJkxhn9bka4/qA3ePT+hymJT3vFGF7kWEUaoZth+tvHnz7QByU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022601; c=relaxed/simple; bh=jR9CdxMLglNBbgTYGpuW+z8E933gcmwRxR/8Zvv09+k=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aOjmkn68JvZ4I+x+FMtP5/yhHnRzBwlar78c3MoB7f+cvYrLrDXZbkohUe4qhBIxD00koG1xKZ+oCwhfsU8L0gEkxz6HxCJjnK0YaUq9p3pcwDlmuHLkcQCf2mTIhr83fUHjw+ssizNoIKvJsFGyKp+gb/RYTZJMV+VtYCllPGs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=KbjEhwQl; arc=none smtp.client-ip=209.85.128.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="KbjEhwQl" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-66498fd4f91so316357b3.3 for ; Fri, 26 Jul 2024 12:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022599; x=1722627399; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=m+sqz5QT4aooITXeocirdSf2pAg4CcNcX0Bi3JXLztg=; b=KbjEhwQlBJ8vEUQLjJW41APVpA59c92fNTcPAmxJoOcb1V+DEw1cQA37oBAZw/miQQ W9v4moWfp6zsVax65maWeNhkd77e3WgX9pR38tidLiDL1bJt33ujNJsyICiXTA764VQq uO7YnkL5WPBjR2KJCKFTlBD36pmeZwO8LbEseWP3BVp+9R8H1/qCi+4bPDVLYXZtNk1l IPiBAxSg5xxs0JSrG1xEwLyPYkpCRGmv/My7IY3DC5LcPl0QQGSwnhPSdxuZu2C7tpIx 4lM4Uj3jW4H+QEJuOVaPoXCD+cJfQ1CT4JagYOelhLFQzEkOpxBnP3QN2XMyvnkbNU0N GTnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022599; x=1722627399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m+sqz5QT4aooITXeocirdSf2pAg4CcNcX0Bi3JXLztg=; b=sLjKsxncZML2CB3T6HxQTScsRoKPfFiZ3rU4fc9cvl1g3zj1Yzj+qCy6hyzpec1mNP iLg/ZrLDHYav2FEJNC/B9/+0572F7fdzoVig5FF33YxvxPDX2XGHUIyIIo5WP3xuwpa8 LozzjwDwv5SD0xq/CdovxiOM6F9Wg0nRQPGyEMNcMGABLqUyzeTEdHRM7oOevTGfhd9a Q47KlW2uszgcw7Cu3lyZQp9fiBQXQ2sird3Saw7DpKv5YGoKcuNUQ1z2xP5VqehEfiP7 XfVgRnceSfCiAnlBLMOd/ErgiJZj6AlgsczftPmwL5/atOW4RelahkZ1ViS2ziL4eQ3u gZHg== X-Gm-Message-State: AOJu0Yyl1aPpjXG6IOttQRubli7jycw41NKy/aK8tc14l+jvtS/pjNtt ei82B54Z96669RQgRgi/p7dr+3mk8E98LmV2I/i2/7ez6SplK4Kf8IRwsZSvih50urb9k/cjjne G X-Google-Smtp-Source: AGHT+IHS2tlzUlfGDZ26zGlzWEkjnbT7D2RIRzvV577R+XZ7kLqwCIqm4U7a+kYJSDw8zITzlAxVog== X-Received: by 2002:a0d:f707:0:b0:62f:cb31:1be with SMTP id 00721157ae682-67a051e8493mr9172377b3.8.1722022599186; Fri, 26 Jul 2024 12:36:39 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756795e987sm9924277b3.39.2024.07.26.12.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:38 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 02/46] btrfs: convert btrfs_read_folio to only use a folio Date: Fri, 26 Jul 2024 15:35:49 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently we're using the page for everything here. Convert this to use the folio helpers instead. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index a4d5f8d00f04..4b7d1881d023 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1155,17 +1155,16 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, int btrfs_read_folio(struct file *file, struct folio *folio) { - struct page *page = &folio->page; - struct btrfs_inode *inode = page_to_inode(page); - u64 start = page_offset(page); - u64 end = start + PAGE_SIZE - 1; + struct btrfs_inode *inode = folio_to_inode(folio); + u64 start = folio_pos(folio); + u64 end = start + folio_size(folio) - 1; struct btrfs_bio_ctrl bio_ctrl = { .opf = REQ_OP_READ }; struct extent_map *em_cached = NULL; int ret; btrfs_lock_and_flush_ordered_range(inode, start, end, NULL); - ret = btrfs_do_readpage(page, &em_cached, &bio_ctrl, NULL); + ret = btrfs_do_readpage(&folio->page, &em_cached, &bio_ctrl, NULL); free_extent_map(em_cached); /* From patchwork Fri Jul 26 19:35:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743071 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.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 9283F4F218 for ; Fri, 26 Jul 2024 19:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022603; cv=none; b=MyxanR4KAX/judN1nCZI3r9h2kdHmI0wEfNPbIQxOu5KLk6hxm19XDZ8TLa3k2FXcldWic99ZgZ0MoVgEiKcyoieBUWGbU/4BQ22GfY+eCt6O3VAu7vPFQ+6NJvTgwfqZAqjVE80atdIBx9/eyU2njjX9OShNjIYtPQivhMiGwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022603; c=relaxed/simple; bh=QAFuT0+trk+M2G01o+RweEYRjOkwm7WV6LU8Et2zAAA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OL015ULPdJx1fEg/T/ir3towTF141W0JeRj6NcjKInKDdqiRDPshySnw1qgouruH8AsuNbUYPpE+iOluyBprOaKVJG4/e7B5Y+9rkwlDei2ICLoLJG4I4oD8KD7fa6JYLg+UXW8gKYUV98x3HuqWIT0+9MadRmghpYqTK6xV+1A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=RtNs3rjI; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="RtNs3rjI" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-6518f8bc182so369617b3.0 for ; Fri, 26 Jul 2024 12:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022600; x=1722627400; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=a8vayj1vlgmUc4MmgD2SMk6LO/kHTwhSl8jAJKCgvng=; b=RtNs3rjIAyDgqPpm7+KUJ9hGCOjSERAQSVYme8I3R8jrcQzIucWjJmmoAZ4cqzZhwo d4CAmh2ARA6DqGz/Fkc8c6KZmoXoE0KRcbRQxARcedWcyrPtzkpcGFh0mbGU5fTGq7Us bHiOAwF+8Ui8t37aCD43N7yw8rphsqqbfaZLS+V7c9XIAgHO+5xqbFw2EUGHJTL0L9Og 5AZqlOGX1chHKVhL3Myxcya30FexLNUVIFHb1OVoTphb7h21WOYf0N9jf9CCoWwNb5Fn mChF5vThtZgRIPNCo0GObV65WDm1tZNst56hnAJA7Nn8B+NKcgbg+XYeiyOjkhll4gSr W2LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022600; x=1722627400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a8vayj1vlgmUc4MmgD2SMk6LO/kHTwhSl8jAJKCgvng=; b=Xyq+ifLpeXJo2jvjFNEY0r8S1Npd/V//57NOBSgAE2SO8EXQlYHcPUSAlnj/AtPUT6 3YoC8Ni7Q3KI+/BaFCra8uM6gKS2rPjOx9+ZLKOj4HAeu+dN8cJg1ar8yAKCrnMiXYDb aSea5wW7+j5MrrHArAqF7VqE6Ak3AWG90r+zzfsM5Z+G4S8XbqEr+CiY8LNlgxMgATQ0 TuU6USzcdNM9TI2SJlnSqw9NE5++KnBOHHu1rS+a8wAnjqOAnbSVjkxrTekML3Fvh3Tx A80M/oRWRerrmpesiJb0/3R0WtIt7YJ4Wn84mQ251FsK2y44o4ng4965RY1h4b96AaRq YBhg== X-Gm-Message-State: AOJu0Yzu+JAaaGrO+7QRTmjxTtsncI6R5h/LiAW7Vx0wUVEgxG7QNCS4 pObElvQDMVgfHBzKFi1CJhmXaJw6si0vxSfSg5kGelib7kYjjNv6KGLfmkheOoGXQc7Dj4UXmcp v X-Google-Smtp-Source: AGHT+IGV/DSDh7JuYsp1tAcOhckyl+ZNvgSuD+EA/NgUwCn+PjnqQ22tYZ4nq3+1xMYkJ+GlDA7yAw== X-Received: by 2002:a81:e307:0:b0:61a:d0d8:75f6 with SMTP id 00721157ae682-67a2dee65e9mr5455517b3.24.1722022600331; Fri, 26 Jul 2024 12:36:40 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756b02492dsm10085947b3.80.2024.07.26.12.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:39 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 03/46] btrfs: convert end_page_read to take a folio Date: Fri, 26 Jul 2024 15:35:50 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We have this helper function to set the page range uptodate once we're done reading it, as well as run fsverity against it. Half of these functions already take a folio, just rename this to end_folio_read and then rework it to take a folio instead, and update everything accordingly. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 4b7d1881d023..2d6b1bc74109 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -406,30 +406,31 @@ void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end, start, end, page_ops); } -static bool btrfs_verify_page(struct page *page, u64 start) +static bool btrfs_verify_folio(struct folio *folio, u64 start, u32 len) { - if (!fsverity_active(page->mapping->host) || - PageUptodate(page) || - start >= i_size_read(page->mapping->host)) + struct btrfs_fs_info *fs_info = folio_to_fs_info(folio); + + if (!fsverity_active(folio->mapping->host) || + btrfs_folio_test_uptodate(fs_info, folio, start, len) || + start >= i_size_read(folio->mapping->host)) return true; - return fsverity_verify_page(page); + return fsverity_verify_folio(folio); } -static void end_page_read(struct page *page, bool uptodate, u64 start, u32 len) +static void end_folio_read(struct folio *folio, bool uptodate, u64 start, u32 len) { - struct btrfs_fs_info *fs_info = page_to_fs_info(page); - struct folio *folio = page_folio(page); + struct btrfs_fs_info *fs_info = folio_to_fs_info(folio); - ASSERT(page_offset(page) <= start && - start + len <= page_offset(page) + PAGE_SIZE); + ASSERT(folio_pos(folio) <= start && + start + len <= folio_pos(folio) + PAGE_SIZE); - if (uptodate && btrfs_verify_page(page, start)) + if (uptodate && btrfs_verify_folio(folio, start, len)) btrfs_folio_set_uptodate(fs_info, folio, start, len); else btrfs_folio_clear_uptodate(fs_info, folio, start, len); - if (!btrfs_is_subpage(fs_info, page->mapping)) - unlock_page(page); + if (!btrfs_is_subpage(fs_info, folio->mapping)) + folio_unlock(folio); else btrfs_subpage_end_reader(fs_info, folio, start, len); } @@ -642,7 +643,7 @@ static void end_bbio_data_read(struct btrfs_bio *bbio) } /* Update page status and unlock. */ - end_page_read(folio_page(folio, 0), uptodate, start, len); + end_folio_read(folio, uptodate, start, len); endio_readpage_release_extent(&processed, BTRFS_I(inode), start, end, uptodate); } @@ -1048,13 +1049,13 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, iosize = PAGE_SIZE - pg_offset; memzero_page(page, pg_offset, iosize); unlock_extent(tree, cur, cur + iosize - 1, NULL); - end_page_read(page, true, cur, iosize); + end_folio_read(page_folio(page), true, cur, iosize); break; } em = __get_extent_map(inode, page, cur, end - cur + 1, em_cached); if (IS_ERR(em)) { unlock_extent(tree, cur, end, NULL); - end_page_read(page, false, cur, end + 1 - cur); + end_folio_read(page_folio(page), false, cur, end + 1 - cur); return PTR_ERR(em); } extent_offset = cur - em->start; @@ -1123,7 +1124,7 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, memzero_page(page, pg_offset, iosize); unlock_extent(tree, cur, cur + iosize - 1, NULL); - end_page_read(page, true, cur, iosize); + end_folio_read(page_folio(page), true, cur, iosize); cur = cur + iosize; pg_offset += iosize; continue; @@ -1131,7 +1132,7 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, /* the get_extent function already copied into the page */ if (block_start == EXTENT_MAP_INLINE) { unlock_extent(tree, cur, cur + iosize - 1, NULL); - end_page_read(page, true, cur, iosize); + end_folio_read(page_folio(page), true, cur, iosize); cur = cur + iosize; pg_offset += iosize; continue; @@ -2551,7 +2552,7 @@ static bool folio_range_has_eb(struct btrfs_fs_info *fs_info, struct folio *foli return true; /* * Even there is no eb refs here, we may still have - * end_page_read() call relying on page::private. + * end_folio_read() call relying on page::private. */ if (atomic_read(&subpage->readers)) return true; From patchwork Fri Jul 26 19:35:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743072 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 C7585132492 for ; Fri, 26 Jul 2024 19:36:42 +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=1722022604; cv=none; b=jmscAqNfhX9I9tmGMOssQFtBk+31N03A86TR6+FfMeEOQX5pSty/Fa/cxRiB1ppz3AvKD4PUFCWmCOi8bGENJ3cHtEkQrkcMww+ppc2r6wIoczqgmsC1Cr1SJKlHJOt1qBMK0VV01rDHlPVeAl6kfn73ce0pbGeTlfCIWwF5gIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022604; c=relaxed/simple; bh=L0ZvvEpFAkvgp5F+ig4n9DgsEv64aYY2210IsqUG82w=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NrzWSjQvOKIgyalgb5Oh6gw2UpA4gxjrafp9+XleRmUhJXJqq8+xeqLbNMTUdETOFBm6wi/Hx65lBQjY/Qi58ffQV8lWaSWt82UJQnoTWThLYjsv5yEucTShdq0Kjf4BdL4rmf2RX1LBKsI4M5tS0mF0HEm5dmC4hCeo4DmmodM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=XOdWRjYw; arc=none smtp.client-ip=209.85.219.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="XOdWRjYw" Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-e0b10e8b6b7so37730276.2 for ; Fri, 26 Jul 2024 12:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022601; x=1722627401; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fG++zUtbtJbYwCXNhQpDX/lMnFuNmR9EVcb6Bxk0CmM=; b=XOdWRjYwob/ogVIGcuBt+9qg3BAnx2eCUkcig0Q394LmRUm2PMTmle3rjSg+Ya4apM PY5oobx3DHuUR+JOcQAGjPyYo/o9Jkm1Q8BPO7N0Pt6lWL1cDywUE1RHzK/3Jl1fwmfN w7uVQ+bgv2fH1zbLjYgDzk1+OsGFin5zgq+p2CdnNkJZ3MCQ4SuH5Ym5qdViZT3mIrYs CPCyEFxpw7scR//gwinFEcFPWyx1T98IUYcueRVdhHjC6pwae+kgGA28tLYPtqO7ASgx 8Q/YTfEhvtVNF166kvTs3T0TDsu7ilrWZsW51+j1b73gOYLk8P+wXZBbBJs6YfiVXc5Z teEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022601; x=1722627401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fG++zUtbtJbYwCXNhQpDX/lMnFuNmR9EVcb6Bxk0CmM=; b=rlYFIoFhLWZduQkfEQjK6B0FZ33AXp8n8+dY0HMvj9pcjtSbSnNyniJhOSrNmNinKJ 09fFld1CQbA+PmbSwmgbu6MdDSy80YmgE7CERtTMxcYBgE4o1w8a130jW0MnfTsjerR9 9wzAwZ77ncNnxU2XYMajXTEUkbZIqy+Pu7CQqH6JLcJXfrYQRkTEbp7CDFhRv9q33tHP Ep7vLN3xv3+ZPFHv3vkUXCHRhxdoVXybySXRf+FlksrFEzPKTiFxwLM/Qae+D2gwYaNq MsLgf0k6QstECzZsPropC69sldE8HOAEm+pR+7acZAiUOiBbXuCk6wU1dowdzlvscnPk e02g== X-Gm-Message-State: AOJu0YwpXc01xG0rxd5W8ZLkFNFBdTPDs6haZDhtyt89ngDwB/92ic2N 02vRDawdEWQ/3mnXqnA3lMYzIs928XduQD2BEwa6x4qFYC3bBdUjF7IV5QOdu73tgwcH+JuxCLb p X-Google-Smtp-Source: AGHT+IFMDPGwEZPMumKFxcDNtbizNon8dZ+UTuPUNvtn49XjaNKHAcrE3FVfd5uxnPlw2PRHC/Y+/w== X-Received: by 2002:a0d:f547:0:b0:64b:6f7f:bc29 with SMTP id 00721157ae682-67a06a0cd24mr9679447b3.16.1722022601465; Fri, 26 Jul 2024 12:36:41 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756b303ec6sm9910347b3.81.2024.07.26.12.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:41 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 04/46] btrfs: convert begin_page_folio to take a folio instead Date: Fri, 26 Jul 2024 15:35:51 -0400 Message-ID: <74d03e343fdfa27baa551fd70afd5252e4f1ee5c.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This already uses a folio internally, change it to take a folio as an argument instead. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 2d6b1bc74109..89938800f37a 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -551,16 +551,14 @@ static void endio_readpage_release_extent(struct processed_extent *processed, processed->uptodate = uptodate; } -static void begin_page_read(struct btrfs_fs_info *fs_info, struct page *page) +static void begin_folio_read(struct btrfs_fs_info *fs_info, struct folio *folio) { - struct folio *folio = page_folio(page); - ASSERT(folio_test_locked(folio)); if (!btrfs_is_subpage(fs_info, folio->mapping)) return; ASSERT(folio_test_private(folio)); - btrfs_subpage_start_reader(fs_info, folio, page_offset(page), PAGE_SIZE); + btrfs_subpage_start_reader(fs_info, folio, folio_pos(folio), PAGE_SIZE); } /* @@ -1038,7 +1036,7 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, } } bio_ctrl->end_io_func = end_bbio_data_read; - begin_page_read(fs_info, page); + begin_folio_read(fs_info, page_folio(page)); while (cur <= end) { enum btrfs_compression_type compress_type = BTRFS_COMPRESS_NONE; bool force_bio_submit = false; From patchwork Fri Jul 26 19:35:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743073 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 ABE0713C906 for ; Fri, 26 Jul 2024 19:36:43 +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=1722022605; cv=none; b=c58zj2o/DWM19Tb3ZbaNeWov2p2unlG2Cdoz4g8POMEs/eQI3rJ+eEx9nGlqslHzOQHU6OAIoVpauBOZ08/T2e1u6jP4/E2als68pBJnuHZ0ruRm0vrH4xRVZaRT9yk+c73HiNdv/FyfGDqPmAFPGl3NmeH+nXQQ5qZ+bhwQFiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022605; c=relaxed/simple; bh=EOQPHU7SEgdcqQwwTcZPHsjTcuYBmIAEmkOd9Tn8XTI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mhdO+YZ0bG8mg0BpFUyvNBEw3GXft09apaEAtNgx1MxwrvVGNJYKaZ4sqc2yGnxzj9D14yBe1ls8yu5nkEIsD+L6PMWyJ6X46OWlKoIjhMiFSmUN0nE8/nq+WUceG+oA8ZBzdycTz+uMxQuTXqlaiCSHU0pnntx+CHW+qBaDnjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=mJGrd3NU; arc=none smtp.client-ip=209.85.219.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="mJGrd3NU" Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-df4d5d0b8d0so28233276.2 for ; Fri, 26 Jul 2024 12:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022602; x=1722627402; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=QQVE0OXmPQ/x7CQKYR+HYJOGhfTjku+I12S77YyhCyc=; b=mJGrd3NUVTypOdiBvO2EYez/iXuZAsQ0IfAqnjfjl1W3PIkEko3dl5ntzoeS80nV3x M9mZOMbt7HN4hKxhDapQVVzx9buDH+FqwRmuolHqmye1cvr7WYxjvnzQFyql80cnwe1O 7PoL0zqmxedvRfkyVCf4mKexbgBgj8Z85iIrEN0/YPX2eyM0LqTN3vPypxDF832/9gBX 2+wHvewyrAdBszARgJ8TTCkZaH2YZMVQ9LwGUYLyjV/uWjrGGlEv36PCyjmVCXOAAnFW TDzifhdFoc4q3vJsjq0ww7JjZU+fdirKqbZOYJ196IKL4zzjJm1I3l/hpXqxKev9X8su nBIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022602; x=1722627402; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QQVE0OXmPQ/x7CQKYR+HYJOGhfTjku+I12S77YyhCyc=; b=cXupqWU43w8ZWea2cd/osxqteGtSV2iB2GA0GuM2GtNF6pi5y4Ck4gipnNKbxeFuk+ Xt3lCEQwc9jttReMOIpt6a7mSRemapFFX9rPjYCpc28OXnRmWjMdVfCcjUWhBDizldO1 B2TVg7AHKox8eGtO/mxHPc8ESfeMjSxu+rqpSMR/Z9Is1jQTZntBgnriMKBD5CcHfrC1 EkSZQ2FtSLbE4d9Ef4aoxEk5QoNLRz6ezDFrnFhkycP27R5AY/HETpokR7Esce1do7l6 yNVSRMBpdCG4pVEiiftCIKnxrZd3O8FcKqluKLkvclnR3tIZAaDB3okuyWxBAaUlfrWW qX+Q== X-Gm-Message-State: AOJu0YwmJAIOZo4/+H9eBTf/vmiz83xEQuFCfWG1W1SyUqDbQbv1uSg+ ukQOn/h/AqTUIsQssrd5O5rj+IlLI7g69auN3Ame2LU/+pfLTSp9KLPEdb3xn+JZLn78uMsnidn q X-Google-Smtp-Source: AGHT+IGwNTHcyc73fVofjO9QTxK0G4jOA6jHrziIU0R4Gh/yfSSfjBFILqQT69ptjsptJA+YmQiGjA== X-Received: by 2002:a05:6902:18cd:b0:e0b:11c6:cf77 with SMTP id 3f1490d57ef6-e0b5444181fmr1049564276.4.1722022602457; Fri, 26 Jul 2024 12:36:42 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0b29f1c269sm850210276.11.2024.07.26.12.36.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:42 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 05/46] btrfs: convert submit_extent_page to use a folio Date: Fri, 26 Jul 2024 15:35:52 -0400 Message-ID: <7e19f07bab70e05871b4dd10be116f6d194f2239.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The callers of this helper are going to be converted to using a folio, so adjust submit_extent_page to become submit_extent_folio and update it to use all the relevant folio helpers. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 89938800f37a..612855e17d04 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -736,12 +736,13 @@ static int alloc_eb_folio_array(struct extent_buffer *eb, bool nofail) } static bool btrfs_bio_is_contig(struct btrfs_bio_ctrl *bio_ctrl, - struct page *page, u64 disk_bytenr, + struct folio *folio, u64 disk_bytenr, unsigned int pg_offset) { struct bio *bio = &bio_ctrl->bbio->bio; struct bio_vec *bvec = bio_last_bvec_all(bio); const sector_t sector = disk_bytenr >> SECTOR_SHIFT; + struct folio *bv_folio = page_folio(bvec->bv_page); if (bio_ctrl->compress_type != BTRFS_COMPRESS_NONE) { /* @@ -754,7 +755,7 @@ static bool btrfs_bio_is_contig(struct btrfs_bio_ctrl *bio_ctrl, /* * The contig check requires the following conditions to be met: * - * 1) The pages are belonging to the same inode + * 1) The folios are belonging to the same inode * This is implied by the call chain. * * 2) The range has adjacent logical bytenr @@ -763,8 +764,8 @@ static bool btrfs_bio_is_contig(struct btrfs_bio_ctrl *bio_ctrl, * This is required for the usage of btrfs_bio->file_offset. */ return bio_end_sector(bio) == sector && - page_offset(bvec->bv_page) + bvec->bv_offset + bvec->bv_len == - page_offset(page) + pg_offset; + folio_pos(bv_folio) + bvec->bv_offset + bvec->bv_len == + folio_pos(folio) + pg_offset; } static void alloc_new_bio(struct btrfs_inode *inode, @@ -817,17 +818,17 @@ static void alloc_new_bio(struct btrfs_inode *inode, * The mirror number for this IO should already be initizlied in * @bio_ctrl->mirror_num. */ -static void submit_extent_page(struct btrfs_bio_ctrl *bio_ctrl, - u64 disk_bytenr, struct page *page, +static void submit_extent_folio(struct btrfs_bio_ctrl *bio_ctrl, + u64 disk_bytenr, struct folio *folio, size_t size, unsigned long pg_offset) { - struct btrfs_inode *inode = page_to_inode(page); + struct btrfs_inode *inode = folio_to_inode(folio); ASSERT(pg_offset + size <= PAGE_SIZE); ASSERT(bio_ctrl->end_io_func); if (bio_ctrl->bbio && - !btrfs_bio_is_contig(bio_ctrl, page, disk_bytenr, pg_offset)) + !btrfs_bio_is_contig(bio_ctrl, folio, disk_bytenr, pg_offset)) submit_one_bio(bio_ctrl); do { @@ -836,7 +837,7 @@ static void submit_extent_page(struct btrfs_bio_ctrl *bio_ctrl, /* Allocate new bio if needed */ if (!bio_ctrl->bbio) { alloc_new_bio(inode, bio_ctrl, disk_bytenr, - page_offset(page) + pg_offset); + folio_pos(folio) + pg_offset); } /* Cap to the current ordered extent boundary if there is one. */ @@ -846,21 +847,22 @@ static void submit_extent_page(struct btrfs_bio_ctrl *bio_ctrl, len = bio_ctrl->len_to_oe_boundary; } - if (bio_add_page(&bio_ctrl->bbio->bio, page, len, pg_offset) != len) { + if (!bio_add_folio(&bio_ctrl->bbio->bio, folio, len, pg_offset)) { /* bio full: move on to a new one */ submit_one_bio(bio_ctrl); continue; } if (bio_ctrl->wbc) - wbc_account_cgroup_owner(bio_ctrl->wbc, page, len); + wbc_account_cgroup_owner(bio_ctrl->wbc, &folio->page, + len); size -= len; pg_offset += len; disk_bytenr += len; /* - * len_to_oe_boundary defaults to U32_MAX, which isn't page or + * len_to_oe_boundary defaults to U32_MAX, which isn't folio or * sector aligned. alloc_new_bio() then sets it to the end of * our ordered extent for writes into zoned devices. * @@ -870,15 +872,15 @@ static void submit_extent_page(struct btrfs_bio_ctrl *bio_ctrl, * boundary is correct. * * When len_to_oe_boundary is U32_MAX, the cap above would - * result in a 4095 byte IO for the last page right before - * we hit the bio limit of UINT_MAX. bio_add_page() has all + * result in a 4095 byte IO for the last folio right before + * we hit the bio limit of UINT_MAX. bio_add_folio() has all * the checks required to make sure we don't overflow the bio, * and we should just ignore len_to_oe_boundary completely * unless we're using it to track an ordered extent. * * It's pretty hard to make a bio sized U32_MAX, but it can * happen when the page cache is able to feed us contiguous - * pages for large extents. + * folios for large extents. */ if (bio_ctrl->len_to_oe_boundary != U32_MAX) bio_ctrl->len_to_oe_boundary -= len; @@ -1143,8 +1145,8 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, if (force_bio_submit) submit_one_bio(bio_ctrl); - submit_extent_page(bio_ctrl, disk_bytenr, page, iosize, - pg_offset); + submit_extent_folio(bio_ctrl, disk_bytenr, page_folio(page), + iosize, pg_offset); cur = cur + iosize; pg_offset += iosize; } @@ -1489,8 +1491,8 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, */ btrfs_folio_clear_dirty(fs_info, page_folio(page), cur, iosize); - submit_extent_page(bio_ctrl, disk_bytenr, page, iosize, - cur - page_offset(page)); + submit_extent_folio(bio_ctrl, disk_bytenr, page_folio(page), + iosize, cur - page_offset(page)); cur += iosize; nr++; } @@ -2087,7 +2089,7 @@ int btree_write_cache_pages(struct address_space *mapping, * extent io tree. Thus we don't want to submit such wild eb * if the fs already has error. * - * We can get ret > 0 from submit_extent_page() indicating how many ebs + * We can get ret > 0 from submit_extent_folio() indicating how many ebs * were submitted. Reset it to 0 to avoid false alerts for the caller. */ if (ret > 0) From patchwork Fri Jul 26 19:35:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743074 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 DD7901411C7 for ; Fri, 26 Jul 2024 19:36: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=1722022606; cv=none; b=THeCM50DJFSPZ97e57pq+31GVwpb1iETnwyHXifMIzKDHzNRO9zce6KSn3n4IShZe1hwpTesNHZG98qewUK1F888hzGskVH+pUtIPNd2nmLVlqDKLOg9G+Z4PS8+LW4ur0WRQXzxsTz9OOeNLtZnqO6oJN300T4e2LvBuVlsjAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022606; c=relaxed/simple; bh=j74CMC07W9scNtCVqoazaUnIHXzUTI0IdDat6me1qAA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mzYazW6H70juXwQpQS3qgZiNJaFy4b42KlIuUjpKuhMD1kzFvV+xZzaPRi89MrRq/4W66/vTQhdJdtAM43uLRJKCPAXWa5f9pVpQeNX3+13ImW4j/rNHZSe0nIuxRPosISTwtEUTTQHcbNKcPVZRfUWULlhlD/ef/EXWS2q1eWo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=fvj8ASLq; arc=none smtp.client-ip=209.85.219.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="fvj8ASLq" Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e0b10e8b6b7so37759276.2 for ; Fri, 26 Jul 2024 12:36:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022604; x=1722627404; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mQUSrK4Jwp1CSW5AxPcMx0ALobcwkzCUtqZnGQVH5AY=; b=fvj8ASLq/UYLKdFYkNenNJ6dUMF1cXsouckcik5icHYzGqw/nhJpNadvPw/x60WjhQ m8qYfozhRni9zdE7Z9BD55cu96CS2zA2qAzd5CfbqbGzvTY+gI47obnPtVu6A/LtcY7C PWjxQWIgt4RWEf6iDvnBYpf1LB4k+io5MNcROMDhhbz0riayWStEB47hrQamDxzvPD7e FwCcP0Jb8z1dUpgtsVBlHwJ0asoEYEpKtza9dvoCmddAMoHc9mfn4Tx70IP88U4vhm/0 OQs6yVqEVfpc70y0yf8h345hCewKUXeAL1uSnLO5hi273dVpFjyGMf+GNZh8DWPnO14J w0Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022604; x=1722627404; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mQUSrK4Jwp1CSW5AxPcMx0ALobcwkzCUtqZnGQVH5AY=; b=IgRcCL73VdjIDqwFG2EEk+UNQAYUawRoRs12iXWyuCWHDKgqiWpRGFp1x6smLwo1tl /6PRtXOi8nomaGQfLxhHr9jTOHe+luXf3xINdnUjkUNl0iMqqh9I5B5Fwb1sJq7inCTc QgA6SfKyPW4R++afd+hZldhNM3QWkhnIgGxSN8wuB6ugZiVik+K66DUI4oYnEmbLZvP9 q+uFGr0uL79k2KytTU4CkoIPM/3jTuBAs0qxlrKtZ1alrdxGktZkwt9BO+ikJqc9CJqk Bf5c4gdv/SBnWzioKqcDcNZYIn5NrCN9LJLcJ76O0b9xa2XWPBwMVdN6bMK1lVSYlfFb xM/Q== X-Gm-Message-State: AOJu0YwyL3VXZBRhLxBzX9NLj7eXB5kn2UUwSTsNB2I1I4b8IqeVYpFP lpWqMYEG2n8qMTCUuJ5QZdoCc2o5cP5d6efeoCV8WaWqcm/r0vL1c4PmIaB4rDVTV8BaSTnJ0+c p X-Google-Smtp-Source: AGHT+IGtoWidu2hDFaMB2Ds2W3BdysAieg0trIdaXCRuJVi5tg5wLoASIg8SmhikM8He2Oh/nERTcA== X-Received: by 2002:a05:6902:2807:b0:e03:53f0:2438 with SMTP id 3f1490d57ef6-e0b543f2cfcmr1111692276.7.1722022603685; Fri, 26 Jul 2024 12:36:43 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0b4ebc5d8fsm176965276.3.2024.07.26.12.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:43 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 06/46] btrfs: convert btrfs_do_readpage to only use a folio Date: Fri, 26 Jul 2024 15:35:53 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that the callers and helpers mostly use folio, convert btrfs_do_readpage to take a folio, and rename it to btrfs_do_read_folio. Update all of the page stuff to use the folio based helpers instead. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 58 ++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 612855e17d04..973028a9ba3f 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1004,12 +1004,12 @@ static struct extent_map *__get_extent_map(struct inode *inode, struct page *pag * XXX JDM: This needs looking at to ensure proper page locking * return 0 on success, otherwise return error */ -static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, +static int btrfs_do_readpage(struct folio *folio, struct extent_map **em_cached, struct btrfs_bio_ctrl *bio_ctrl, u64 *prev_em_start) { - struct inode *inode = page->mapping->host; + struct inode *inode = folio->mapping->host; struct btrfs_fs_info *fs_info = inode_to_fs_info(inode); - u64 start = page_offset(page); + u64 start = folio_pos(folio); const u64 end = start + PAGE_SIZE - 1; u64 cur = start; u64 extent_offset; @@ -1022,23 +1022,23 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, size_t blocksize = fs_info->sectorsize; struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; - ret = set_page_extent_mapped(page); + ret = set_folio_extent_mapped(folio); if (ret < 0) { unlock_extent(tree, start, end, NULL); - unlock_page(page); + folio_unlock(folio); return ret; } - if (page->index == last_byte >> PAGE_SHIFT) { - size_t zero_offset = offset_in_page(last_byte); + if (folio->index == last_byte >> folio_shift(folio)) { + size_t zero_offset = offset_in_folio(folio, last_byte); if (zero_offset) { - iosize = PAGE_SIZE - zero_offset; - memzero_page(page, zero_offset, iosize); + iosize = folio_size(folio) - zero_offset; + folio_zero_range(folio, zero_offset, iosize); } } bio_ctrl->end_io_func = end_bbio_data_read; - begin_folio_read(fs_info, page_folio(page)); + begin_folio_read(fs_info, folio); while (cur <= end) { enum btrfs_compression_type compress_type = BTRFS_COMPRESS_NONE; bool force_bio_submit = false; @@ -1046,16 +1046,17 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, ASSERT(IS_ALIGNED(cur, fs_info->sectorsize)); if (cur >= last_byte) { - iosize = PAGE_SIZE - pg_offset; - memzero_page(page, pg_offset, iosize); + iosize = folio_size(folio) - pg_offset; + folio_zero_range(folio, pg_offset, iosize); unlock_extent(tree, cur, cur + iosize - 1, NULL); - end_folio_read(page_folio(page), true, cur, iosize); + end_folio_read(folio, true, cur, iosize); break; } - em = __get_extent_map(inode, page, cur, end - cur + 1, em_cached); + em = __get_extent_map(inode, folio_page(folio, 0), cur, + end - cur + 1, em_cached); if (IS_ERR(em)) { unlock_extent(tree, cur, end, NULL); - end_folio_read(page_folio(page), false, cur, end + 1 - cur); + end_folio_read(folio, false, cur, end + 1 - cur); return PTR_ERR(em); } extent_offset = cur - em->start; @@ -1080,8 +1081,8 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, * to the same compressed extent (possibly with a different * offset and/or length, so it either points to the whole extent * or only part of it), we must make sure we do not submit a - * single bio to populate the pages for the 2 ranges because - * this makes the compressed extent read zero out the pages + * single bio to populate the folios for the 2 ranges because + * this makes the compressed extent read zero out the folios * belonging to the 2nd range. Imagine the following scenario: * * File layout @@ -1094,13 +1095,13 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, * [extent X, compressed length = 4K uncompressed length = 16K] * * If the bio to read the compressed extent covers both ranges, - * it will decompress extent X into the pages belonging to the + * it will decompress extent X into the folios belonging to the * first range and then it will stop, zeroing out the remaining - * pages that belong to the other range that points to extent X. + * folios that belong to the other range that points to extent X. * So here we make sure we submit 2 bios, one for the first * range and another one for the third range. Both will target * the same physical extent from disk, but we can't currently - * make the compressed bio endio callback populate the pages + * make the compressed bio endio callback populate the folios * for both ranges because each compressed bio is tightly * coupled with a single extent map, and each range can have * an extent map with a different offset value relative to the @@ -1121,18 +1122,18 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, /* we've found a hole, just zero and go on */ if (block_start == EXTENT_MAP_HOLE) { - memzero_page(page, pg_offset, iosize); + folio_zero_range(folio, pg_offset, iosize); unlock_extent(tree, cur, cur + iosize - 1, NULL); - end_folio_read(page_folio(page), true, cur, iosize); + end_folio_read(folio, true, cur, iosize); cur = cur + iosize; pg_offset += iosize; continue; } - /* the get_extent function already copied into the page */ + /* the get_extent function already copied into the folio */ if (block_start == EXTENT_MAP_INLINE) { unlock_extent(tree, cur, cur + iosize - 1, NULL); - end_folio_read(page_folio(page), true, cur, iosize); + end_folio_read(folio, true, cur, iosize); cur = cur + iosize; pg_offset += iosize; continue; @@ -1145,8 +1146,8 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, if (force_bio_submit) submit_one_bio(bio_ctrl); - submit_extent_folio(bio_ctrl, disk_bytenr, page_folio(page), - iosize, pg_offset); + submit_extent_folio(bio_ctrl, disk_bytenr, folio, iosize, + pg_offset); cur = cur + iosize; pg_offset += iosize; } @@ -1165,7 +1166,7 @@ int btrfs_read_folio(struct file *file, struct folio *folio) btrfs_lock_and_flush_ordered_range(inode, start, end, NULL); - ret = btrfs_do_readpage(&folio->page, &em_cached, &bio_ctrl, NULL); + ret = btrfs_do_readpage(folio, &em_cached, &bio_ctrl, NULL); free_extent_map(em_cached); /* @@ -2369,8 +2370,7 @@ void btrfs_readahead(struct readahead_control *rac) btrfs_lock_and_flush_ordered_range(inode, start, end, NULL); while ((folio = readahead_folio(rac)) != NULL) - btrfs_do_readpage(&folio->page, &em_cached, &bio_ctrl, - &prev_em_start); + btrfs_do_readpage(folio, &em_cached, &bio_ctrl, &prev_em_start); if (em_cached) free_extent_map(em_cached); From patchwork Fri Jul 26 19:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743075 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 C0298143759 for ; Fri, 26 Jul 2024 19:36:45 +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=1722022607; cv=none; b=Uyrb+sx4M0JcB+rrSGP+gkPjwzwcCfmQ+Aeq1H3WTSQ8IH98tO+W8BXyvyxVvFm4+jPwvdjOyEqDnOdi+EQXhl+clqzWjqyG6DJeY+gdN/boNMwDFzTL3dHm6gbKd7PlKpvZIJX9w+DSoE40okoX2Zyj9mJ4houZEUm019SsDIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022607; c=relaxed/simple; bh=3bPbADCS2HpfhslYpNioSuMX/epY9LtEf3G8hvbnK34=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bdu3BzZzI3yYYKjmN6ROJccUpsm44k3RKiQc07Y3y3RovMGr47Zs3jAn9CTPicrNlOnfBMdbTtfjKbJ9KPIY4qhtgw5Yf2/IpsFdsK0fKBZIHrcsdbr3ZXXlvqOY37h7y2guSRkEJBIvJvHwMnuInjQpks1/dFrNdxbrzukFeQ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=tMEikmd/; arc=none smtp.client-ip=209.85.128.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="tMEikmd/" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-66599ca3470so395947b3.2 for ; Fri, 26 Jul 2024 12:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022605; x=1722627405; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=K1tPlUcBg+AQjlcZOU2aBLx99C3Jfi1gm9Dpkd3CfrI=; b=tMEikmd/b8pSfNbYMCWiYycDThYrP/+YMylr0nOMnQadu3otC1ampZ46Adjg/CPf3I t3ZDFlnte3Sd1Smi9CgI+k3GmaKiaTLgtFT0Uu/cKeN/f4z+BTsmD348TqGqmb3BQIj2 W7lSpH+SGO6RhxhqkSULvooBPwiRORkMzkR0XEjg6SG4D9BohAMzKmFTM567C1TONYqV MLnlG4MtdU2BxWDe8GUpO/gQRN2r5d1Dh8Ksdyo0QOgtQSmHe+XT6n0QJRe0mRx9t/XP TxEHWp6eHLpoVcT6p8+rps4UVB/hNJ40Z+ngbE7cEkld+98Myq+3UCgkVrrau9tSYZhD rMTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022605; x=1722627405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K1tPlUcBg+AQjlcZOU2aBLx99C3Jfi1gm9Dpkd3CfrI=; b=ZvfXWNXzFst7VrtoWYYt3aTBTIa/B14nc0c014K0yHM0IYQqsob8I9hkSW2xyp5+Zx AXIifyP8WaDsMhA8Fb7EwI+oiD9VAsYQBxc9KW/7orQtMJMa+weSiyAtooRge3UDtW0u 0qG6NqeOyrBWcrKoRQIviFr6vmDcjFJOaXMoZMUVUWBm/hp0hOkxETWkeIhHlxCOAxfB W74rKdPTYy5OQjoDohdpZVfDQsCSd1N0y0ul9+elKu3UjrsGKcb7lQVFxFYIsOViO6gw lnxt4igmvnO+bWS1kbi0w77pysxbtHpwMHJNkrxYIJYMl0mqcj5pHxcvMUAqgD2oqFbc HGAQ== X-Gm-Message-State: AOJu0YwauzwO3vaBJdkutXMd/XIkElakf/D4tF9hesYPXPVr0dctQRic t4MV9uwv5urVyYcwM3oe4ONY9anJCiqCHeZrai2Vjocn9Zheyt0Dryzx48WMQk9ECW4eQoZM3Jh I X-Google-Smtp-Source: AGHT+IGTJGpi+AwKXS3QmEnY1AVDG3uHlPLeRI4TpoNj9gNuGG9L7ax3ROoTgyBGzFbH9UYv3ujMAA== X-Received: by 2002:a05:690c:ec5:b0:63b:df6e:3f6d with SMTP id 00721157ae682-67a0a7fc533mr10170997b3.37.1722022604735; Fri, 26 Jul 2024 12:36:44 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756bab5090sm9959487b3.120.2024.07.26.12.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:44 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 07/46] btrfs: update the writepage tracepoint to take a folio Date: Fri, 26 Jul 2024 15:35:54 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Willy is wanting to get rid of page->index, convert the writepage tracepoint to take a folio so we can do folio->index instead of page->index. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 2 +- include/trace/events/btrfs.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 973028a9ba3f..eed2be8afb15 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1531,7 +1531,7 @@ static int __extent_writepage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl loff_t i_size = i_size_read(inode); unsigned long end_index = i_size >> PAGE_SHIFT; - trace___extent_writepage(page, inode, bio_ctrl->wbc); + trace___extent_writepage(folio, inode, bio_ctrl->wbc); WARN_ON(!PageLocked(page)); diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index eeb56975bee7..3af681642652 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -674,10 +674,10 @@ TRACE_EVENT(btrfs_finish_ordered_extent, DECLARE_EVENT_CLASS(btrfs__writepage, - TP_PROTO(const struct page *page, const struct inode *inode, + TP_PROTO(const struct folio *folio, const struct inode *inode, const struct writeback_control *wbc), - TP_ARGS(page, inode, wbc), + TP_ARGS(folio, inode, wbc), TP_STRUCT__entry_btrfs( __field( u64, ino ) @@ -695,7 +695,7 @@ DECLARE_EVENT_CLASS(btrfs__writepage, TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), __entry->ino = btrfs_ino(BTRFS_I(inode)); - __entry->index = page->index; + __entry->index = folio->index; __entry->nr_to_write = wbc->nr_to_write; __entry->pages_skipped = wbc->pages_skipped; __entry->range_start = wbc->range_start; @@ -723,10 +723,10 @@ DECLARE_EVENT_CLASS(btrfs__writepage, DEFINE_EVENT(btrfs__writepage, __extent_writepage, - TP_PROTO(const struct page *page, const struct inode *inode, + TP_PROTO(const struct folio *folio, const struct inode *inode, const struct writeback_control *wbc), - TP_ARGS(page, inode, wbc) + TP_ARGS(folio, inode, wbc) ); TRACE_EVENT(btrfs_writepage_end_io_hook, From patchwork Fri Jul 26 19:35:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743076 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.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 CD4A1143C6A for ; Fri, 26 Jul 2024 19:36:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022608; cv=none; b=HucHQXa7pag7PLUXGDqprSe05bC0MLzUqxYL2JA8SopIFkxYIr7K2Qs6pdVhtx26z9mIV/ZwhNkqJjsvY3wHFLsM2/B+v09VqTGaCDTAtrY94+ZIbFbUayT2XXFe7trCdR3UQUyl0it2Ksd+TbnvpYt1ptVmG+dsadlYhFmesGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022608; c=relaxed/simple; bh=smJ3oJGi/hR7bVqUSKm5VxzskmNoj2QriIrYoBI2+xg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mRvP+pofL/fr6uO7vw29+B0E8mg9U0k9eKpM2WPS5HdYOb6H3kx8ReOf8kxmeDrzJqCTYDQGfR+bA7CsOvn3FjJLRXVrfGna2qGsjhnxm3/g3D3XZD23zLGzvKX6rvC6mHwFoLJgFIJdp7eEjUyfxEXTAPwttnJq9q6AD5+FCuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=vq2G8wRj; arc=none smtp.client-ip=209.85.128.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="vq2G8wRj" Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-66ca536621cso365387b3.3 for ; Fri, 26 Jul 2024 12:36:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022606; x=1722627406; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=su8I1Qi4RIXhQjrMv08oU20JDQbK08zGBUZyC/v4mMg=; b=vq2G8wRjUzMe7Z3gYKq4Z5g0CWixIFbhZonWZ6qNUQ1dIHsiZoOQwgPVgM/xmWpinv 0qxhjrAlFpKZXbw557S/La2BQJ6Zqdgs+I+IBsBSrbglKpchNvF8gfFFG+apakdX2hkX F+BqeMuD2UsQL4aQs2dh3Jk1mMGEVc6kAzbKqPJw75RzJDa+b1mT48YgZQ5MIjMT+gdF o62Q2b2pfS/ENlwqvZIBV3z75gO9W5313pP45C3fzUxE8dYPS0P8kcT3VTBvD0m4QmRd gmIiDKdFyRoh+DMhihiDeakJiS4F+dAGM+A8e3HefbkC98pUvUeaDhAiDf92L/8GDMAY 8F3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022606; x=1722627406; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=su8I1Qi4RIXhQjrMv08oU20JDQbK08zGBUZyC/v4mMg=; b=ElEKGQZgJma1c7/gJVQxWt8GUw7kaHFZHt/9ApxkuPxaLMEDJ+ZZbXU2n6QibxWPwp LxHKVLkzwbOmUnai331VC65L4QD2a0Ge9M0vvmix0iYiSZPT6BLVcF8Y5LZCb85V7Scq jSymwOZvSjmmGsKkcrSHDTTG7bJvP5iaBxFrPgP3GEPMTowdaLMD66UEVpwmk3S76EfQ eApx5LhmWtikVxunKK3qoH6APcdAD2Ro1zBXHsI6TlHNHyivQi9uFsCimFlLqsalM6XG 2gpYKt969jr3yz3RCmK+AIdxigjJ7PjlBllom5uc9F4E0RqvR3Ipboj+XaycoZCg2lon rkBA== X-Gm-Message-State: AOJu0YzXjJ0hYwqGW0XxoGJLNLtK+JE04Tu28UcSt/HzhdoWSwXFumSv eP0mKEVqTeUOnCJQoHEI0oLwXqZmOGtzq8Q2Ee6s12CgOX8LBtu3rZ4iG6U9D1soaAWpWuq/ZaH c X-Google-Smtp-Source: AGHT+IGJdsMl9fnb9+j11YbwHFM/3LOMiUeKFMT1ApKCV0emioVh1skissxa4yz3Ol4qwmiMkFUzGg== X-Received: by 2002:a05:690c:ed3:b0:631:4dc:f6e5 with SMTP id 00721157ae682-67a090a5ef6mr9225397b3.36.1722022605767; Fri, 26 Jul 2024 12:36:45 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756b9bd90dsm9852267b3.104.2024.07.26.12.36.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:45 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 08/46] btrfs: convert __extent_writepage_io to take a folio Date: Fri, 26 Jul 2024 15:35:55 -0400 Message-ID: <206c887fcee49fbcf0a246f55256b9f56b3f63c4.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 __extent_writepage_io uses page everywhere, but a lot of these functions take a folio. Convert it to use the folio based helpers, and then change it to take a folio as an argument and update its callers. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index eed2be8afb15..63ec7efd307f 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1393,10 +1393,10 @@ static void find_next_dirty_byte(const struct btrfs_fs_info *fs_info, * < 0 if there were errors (page still locked) */ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, - struct page *page, u64 start, u32 len, - struct btrfs_bio_ctrl *bio_ctrl, - loff_t i_size, - int *nr_ret) + struct folio *folio, + u64 start, u32 len, + struct btrfs_bio_ctrl *bio_ctrl, + loff_t i_size, int *nr_ret) { struct btrfs_fs_info *fs_info = inode->root->fs_info; u64 cur = start; @@ -1407,14 +1407,14 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, int ret = 0; int nr = 0; - ASSERT(start >= page_offset(page) && - start + len <= page_offset(page) + PAGE_SIZE); + ASSERT(start >= folio_pos(folio) && + start + len <= folio_pos(folio) + folio_size(folio)); - ret = btrfs_writepage_cow_fixup(page); + ret = btrfs_writepage_cow_fixup(&folio->page); if (ret) { /* Fixup worker will requeue */ - redirty_page_for_writepage(bio_ctrl->wbc, page); - unlock_page(page); + folio_redirty_for_writepage(bio_ctrl->wbc, folio); + folio_unlock(folio); return 1; } @@ -1428,21 +1428,21 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, u32 iosize; if (cur >= i_size) { - btrfs_mark_ordered_io_finished(inode, page, cur, len, - true); + btrfs_mark_ordered_io_finished(inode, &folio->page, cur, + len, true); /* * This range is beyond i_size, thus we don't need to * bother writing back. * But we still need to clear the dirty subpage bit, or - * the next time the page gets dirtied, we will try to + * the next time the folio gets dirtied, we will try to * writeback the sectors with subpage dirty bits, * causing writeback without ordered extent. */ - btrfs_folio_clear_dirty(fs_info, page_folio(page), cur, len); + btrfs_folio_clear_dirty(fs_info, folio, cur, len); break; } - find_next_dirty_byte(fs_info, page, &dirty_range_start, + find_next_dirty_byte(fs_info, &folio->page, &dirty_range_start, &dirty_range_end); if (cur < dirty_range_start) { cur = dirty_range_start; @@ -1478,33 +1478,33 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, em = NULL; btrfs_set_range_writeback(inode, cur, cur + iosize - 1); - if (!PageWriteback(page)) { + if (!folio_test_writeback(folio)) { btrfs_err(inode->root->fs_info, - "page %lu not writeback, cur %llu end %llu", - page->index, cur, end); + "folio %lu not writeback, cur %llu end %llu", + folio->index, cur, end); } /* * Although the PageDirty bit is cleared before entering this * function, subpage dirty bit is not cleared. * So clear subpage dirty bit here so next time we won't submit - * page for range already written to disk. + * folio for range already written to disk. */ - btrfs_folio_clear_dirty(fs_info, page_folio(page), cur, iosize); + btrfs_folio_clear_dirty(fs_info, folio, cur, iosize); - submit_extent_folio(bio_ctrl, disk_bytenr, page_folio(page), - iosize, cur - page_offset(page)); + submit_extent_folio(bio_ctrl, disk_bytenr, folio, + iosize, cur - folio_pos(folio)); cur += iosize; nr++; } - btrfs_folio_assert_not_dirty(fs_info, page_folio(page), start, len); + btrfs_folio_assert_not_dirty(fs_info, folio, start, len); *nr_ret = nr; return 0; out_error: /* - * If we finish without problem, we should not only clear page dirty, + * If we finish without problem, we should not only clear folio dirty, * but also empty subpage dirty bits */ *nr_ret = nr; @@ -1556,7 +1556,7 @@ static int __extent_writepage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl if (ret) goto done; - ret = __extent_writepage_io(BTRFS_I(inode), page, page_offset(page), + ret = __extent_writepage_io(BTRFS_I(inode), folio, folio_pos(folio), PAGE_SIZE, bio_ctrl, i_size, &nr); if (ret == 1) return 0; @@ -2308,7 +2308,7 @@ void extent_write_locked_range(struct inode *inode, const struct page *locked_pa if (pages_dirty && page != locked_page) ASSERT(PageDirty(page)); - ret = __extent_writepage_io(BTRFS_I(inode), page, cur, cur_len, + ret = __extent_writepage_io(BTRFS_I(inode), page_folio(page), cur, cur_len, &bio_ctrl, i_size, &nr); if (ret == 1) goto next_page; From patchwork Fri Jul 26 19:35:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743077 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 C7807145A0B for ; Fri, 26 Jul 2024 19:36:47 +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=1722022609; cv=none; b=eOGp8qsDgAiuUgvwWxKABVO6T7zNBwskPJDjQrDxUdNguG4roF5FXZTthT1YnQUfzIw+IGtjKs0HW97b3OVHS6pP6mRKlRGUsJATnDD+pmKNYjjb2J0rggG5+jfXqg8pIYYjCwRFt8tpHJlkep/mc3jfUhw5T3ZkHi9jc16H5pM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022609; c=relaxed/simple; bh=RHMou5NJiO55eFD4jOnffqywkq/ozNpV2heuO7MUYis=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lKWjdg4aF10jwKfULFeJJ1KJJuYQjQzpT9MDKoI1rFLKZmDI44rIi+Prky8IU6AxjZ6pVo/ZHHcJYlASTwrNxXYImOh7Ly4l+ttwwgO1DHPGCuSr9/lDJeNMpVx1ucxDPHOuzFuM5XgZmfV4aW5QL3WFIg+yYp8FjF4VVGBfJxQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=jMYdK48X; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="jMYdK48X" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-66a1842b452so241357b3.3 for ; Fri, 26 Jul 2024 12:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022607; x=1722627407; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=o1Qm9mvhcCU978341Wg7EEf+4K0yvkNVlGaIoPUcIAM=; b=jMYdK48XjL3M2wHPIU5FKwiSARMO10LYGZGe4o9bSVUQBdXlSMBHA73BjyRvtxZTQh wkpd/w4lWFMSjg6+rUKNS54OfDOA85tshmxiCWhRDtySv/jBztJzAJqfrf7tRJgXNoxs u8EdUo1t7hv0/ESsq0vWOr7oVlTeZvIw7Drzzqh1Fk6h2NXr8PQict1EzBuJpetk8MnF 2FKXoSzWyNf7eb2Csvu9xMGvFpna8p30bXVcBRpy5Dsbjw2pQlYvdxblJfiXa1qs0c0H V68hOnXZ79VmYSjQZHcfnHVGMjyvliGYJt/R9/kVnvZUXLyOYYR/j5TTdwDDwPC78awh /B6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022607; x=1722627407; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o1Qm9mvhcCU978341Wg7EEf+4K0yvkNVlGaIoPUcIAM=; b=NE/lov6vm5exvs4IpspN8VDUr8bbg/IwTjvFIJXc2v9XJupEaFm3XLYRwcuzW4x4qY lfX1toVAl+Kzsc2p1rGNJ8YAZfQcpoGY6iv/qzdZY8iyaEN7tKN9JRHiWpqLN+Dkxmz5 4PLxxtKLQbj8SDpGL4VTMGKEJv99/wbJVKaVLElP6G+Vrpy3ruQIwkPWpCk4TgmKNcr/ 4T3bsUttFZxM30V8RDeLKqG/1HxVF3yWCYhp8xrFkKQQvlBL5K1OB/LnxIWu7b7lbxvG omKaVtTZauabfdm/dxFWhBByDd7IrQDJCSF0waYxVc/QnSwYScdykHJjebUXd15mrK66 wsrw== X-Gm-Message-State: AOJu0YwoAHzdKgTQvqph6gCY9Fm1vBF1ZVujJK9+pdTppIFAfsUICMD/ UEF0R+FbEL8hyuW+526tjlA5ea4J+2sC55gRjEd5mrpALRRuK7akS+Xd4xeuQbMXmCyBVYaIUOt I X-Google-Smtp-Source: AGHT+IH77liTOi8yS+dTaGT2pvL0QcgsOoc6klwNTeMEUEmXMEM8cdG1S2bp05RDMKiF1xucxursTQ== X-Received: by 2002:a05:690c:698c:b0:64a:5ff5:73ef with SMTP id 00721157ae682-679fffd70eamr13229507b3.0.1722022606721; Fri, 26 Jul 2024 12:36:46 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67566dd90f2sm10019897b3.11.2024.07.26.12.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:46 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 09/46] btrfs: convert extent_write_locked_range to use folios Date: Fri, 26 Jul 2024 15:35:56 -0400 Message-ID: <10ac7f2cbef3070ec1134f4472c967d00ca74603.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of using pages for everything, find a folio and use that. This makes things a bit cleaner as a lot of the functions calls here all take folios. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 63ec7efd307f..a04fc920b0e6 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2300,37 +2300,47 @@ void extent_write_locked_range(struct inode *inode, const struct page *locked_pa while (cur <= end) { u64 cur_end = min(round_down(cur, PAGE_SIZE) + PAGE_SIZE - 1, end); u32 cur_len = cur_end + 1 - cur; - struct page *page; + struct folio *folio; int nr = 0; - page = find_get_page(mapping, cur >> PAGE_SHIFT); - ASSERT(PageLocked(page)); - if (pages_dirty && page != locked_page) - ASSERT(PageDirty(page)); + folio = __filemap_get_folio(mapping, cur >> PAGE_SHIFT, 0, 0); - ret = __extent_writepage_io(BTRFS_I(inode), page_folio(page), cur, cur_len, + /* + * This shouldn't happen, the pages are pinned and locked, this + * code is just in case, but shouldn't actually be run. + */ + if (IS_ERR(folio)) { + btrfs_mark_ordered_io_finished(BTRFS_I(inode), NULL, + cur, cur_len, false); + mapping_set_error(mapping, PTR_ERR(folio)); + cur = cur_end + 1; + continue; + } + + ASSERT(folio_test_locked(folio)); + if (pages_dirty && &folio->page != locked_page) + ASSERT(folio_test_dirty(folio)); + + ret = __extent_writepage_io(BTRFS_I(inode), folio, cur, cur_len, &bio_ctrl, i_size, &nr); if (ret == 1) goto next_page; /* Make sure the mapping tag for page dirty gets cleared. */ if (nr == 0) { - struct folio *folio; - - folio = page_folio(page); btrfs_folio_set_writeback(fs_info, folio, cur, cur_len); btrfs_folio_clear_writeback(fs_info, folio, cur, cur_len); } if (ret) { - btrfs_mark_ordered_io_finished(BTRFS_I(inode), page, + btrfs_mark_ordered_io_finished(BTRFS_I(inode), &folio->page, cur, cur_len, !ret); - mapping_set_error(page->mapping, ret); + mapping_set_error(mapping, ret); } - btrfs_folio_unlock_writer(fs_info, page_folio(page), cur, cur_len); + btrfs_folio_unlock_writer(fs_info, folio, cur, cur_len); if (ret < 0) found_error = true; next_page: - put_page(page); + folio_put(folio); cur = cur_end + 1; } From patchwork Fri Jul 26 19:35:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743078 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.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 D2010146A7D for ; Fri, 26 Jul 2024 19:36:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022610; cv=none; b=AiDx7WmlfALMpz6dRATlQWIT909UCs0GWZ7rOZXGJaDotF5lza7sqMt3+gJY4WztgUsAD8AQwelukb/rrz7LIaA6VpTxzgcO3FyP3iGWd6XeqjoiATIU/nLCprIQjKvk9QQXDsc1z1GJeneSR23cEhsTC4/jeWLWfYuJiR/ktMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022610; c=relaxed/simple; bh=vRrpX6Kgy2Vbi7oe3Xoy+DLXJlW2rKujOJW0hBAuGHI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZPQYHNmjQHnYzO/8csrd6CeZmhBMG4ZOC687EGowDrIR1HVNMAwZzss50i5HZpNRKGPOwGaMOYUAjsu8qzpU980DJs8Varijd3db1MWXGpV2NuA/Dx6JSSfC20o18UMtvrACRYlL+1Vv0NOJjoZytihIAMnVvMKop6f7fREXgPI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=ayUgLa6I; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="ayUgLa6I" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-654cf0a069eso438247b3.1 for ; Fri, 26 Jul 2024 12:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022608; x=1722627408; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fTbWb29wHaRmWuDNJdN7gFQyOcLAcSOY6phM460fSR8=; b=ayUgLa6ILmGgVxCOl0OCs+qBoXeeAFQ0Hro/g7s8Vnawy5qm4qBihJ6wYAEWWf73uD wD9oW+n9BxLDyi0m1tBWB3cJXjeTzBgGE0jw7VE8cor02uIBzL/dC7Xfl3Bvzs5a8+wH XvoA0wJIvwy2pg1+hO9/tGZVwo3SWEMrVd8D/xWbRCbkF+eZWx0U15eqnyPrjSZ9DsP8 tAtw10p155+znh+OFu5VoSurvv7X+ogN665A3l0fE9tpl4dH0Qz/WtbX/pWzSy+y0K74 MyyNONz5nXqlPSXvCwt6T5pv9xv2GVfAhrQmhgQAiAXQ7MLGOiMmOEhL9Z8aoypPRn6U 6u5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022608; x=1722627408; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fTbWb29wHaRmWuDNJdN7gFQyOcLAcSOY6phM460fSR8=; b=dsfKa5Z1pjHWho/QkYPVp43CeXmm/j02iehfAKiUX4brZeYzY+/AJL2MA7TLtgKoT4 bVkX1oTzPTWWklJVTgcCcMPYCvRU8omzgf2lLms0lCQtcVZeBpCsgt647xZdEF7MmATv 0fZaJ9OE092hzMSHp1QPYXyjLjabN8q+xu9/g5g0j8LAAEdfNxFb4NlgDWgBvwIaiVue ADUNbakIzIhAIWiy3p2+9vIgVPaJ6spkg0q//0pxPUt24sIfjs21JtJmimxlwYhr0r8v jwbaiR8/fYInPDRYFzO6zzhMsSGfrpogWrL1YlYlG7NJDXu5relT2zFtgJK/PCNkanAg dxog== X-Gm-Message-State: AOJu0YwS5jwBLZ7rujOd0gf2gEwqeadNAfRzIGotCC9pfvwoPMPo5EIQ C+YAtGFHFWq/y+n/Cf3cud2pcCB0YJv1HDIAZ0nCpX4D95jtkUn407izLM+dsCuZiuTmtw9Avjr 8 X-Google-Smtp-Source: AGHT+IFwmGcDkU1aWw8D9eor1p8lmQDUVhY4PJUZJJi04+T1m/qU+FPt10iKKlI3qzWm/8WEAr/IIw== X-Received: by 2002:a0d:c641:0:b0:65f:e307:d41 with SMTP id 00721157ae682-67a06a0c051mr9753907b3.16.1722022607750; Fri, 26 Jul 2024 12:36:47 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756795e61csm10032237b3.42.2024.07.26.12.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:47 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 10/46] btrfs: convert __extent_writepage to be completely folio based Date: Fri, 26 Jul 2024 15:35:57 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that we've gotten most of the helpers updated to only take a folio, update __extent_writepage to only deal in folios. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index a04fc920b0e6..da60ec1e866a 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1520,11 +1520,10 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, * Return 0 if everything goes well. * Return <0 for error. */ -static int __extent_writepage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl) +static int __extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrl) { - struct folio *folio = page_folio(page); - struct inode *inode = page->mapping->host; - const u64 page_start = page_offset(page); + struct inode *inode = folio->mapping->host; + const u64 page_start = folio_pos(folio); int ret; int nr = 0; size_t pg_offset; @@ -1533,24 +1532,24 @@ static int __extent_writepage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl trace___extent_writepage(folio, inode, bio_ctrl->wbc); - WARN_ON(!PageLocked(page)); + WARN_ON(!folio_test_locked(folio)); - pg_offset = offset_in_page(i_size); - if (page->index > end_index || - (page->index == end_index && !pg_offset)) { + pg_offset = offset_in_folio(folio, i_size); + if (folio->index > end_index || + (folio->index == end_index && !pg_offset)) { folio_invalidate(folio, 0, folio_size(folio)); folio_unlock(folio); return 0; } - if (page->index == end_index) - memzero_page(page, pg_offset, PAGE_SIZE - pg_offset); + if (folio->index == end_index) + folio_zero_range(folio, pg_offset, folio_size(folio) - pg_offset); - ret = set_page_extent_mapped(page); + ret = set_folio_extent_mapped(folio); if (ret < 0) goto done; - ret = writepage_delalloc(BTRFS_I(inode), page, bio_ctrl->wbc); + ret = writepage_delalloc(BTRFS_I(inode), &folio->page, bio_ctrl->wbc); if (ret == 1) return 0; if (ret) @@ -1566,13 +1565,13 @@ static int __extent_writepage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl done: if (nr == 0) { /* make sure the mapping tag for page dirty gets cleared */ - set_page_writeback(page); - end_page_writeback(page); + folio_start_writeback(folio); + folio_end_writeback(folio); } if (ret) { - btrfs_mark_ordered_io_finished(BTRFS_I(inode), page, page_start, - PAGE_SIZE, !ret); - mapping_set_error(page->mapping, ret); + btrfs_mark_ordered_io_finished(BTRFS_I(inode), &folio->page, + page_start, PAGE_SIZE, !ret); + mapping_set_error(folio->mapping, ret); } btrfs_folio_end_all_writers(inode_to_fs_info(inode), folio); @@ -2229,7 +2228,7 @@ static int extent_write_cache_pages(struct address_space *mapping, continue; } - ret = __extent_writepage(&folio->page, bio_ctrl); + ret = __extent_writepage(folio, bio_ctrl); if (ret < 0) { done = 1; break; From patchwork Fri Jul 26 19:35:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743079 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 E318414830D for ; Fri, 26 Jul 2024 19:36:49 +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=1722022611; cv=none; b=ZansR4brEbs+4LxfALJ4l0qFNMD097jv6cDcJpJKOurzTubw4pZXAG/7K4MZoREgb/g8K+4qypMQ6fFyn4zI9AyLiyuyjC0y7m0sce0237TJGJ9/6hAMliwQfxEewqTLnA2Y5Fje8vmIfhLk0j9GrCkZuC2B94tn6EYhllQBqU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022611; c=relaxed/simple; bh=jpzqse+sJwITVScHg11kpahLKpVH6EhTUgUvkvScyPc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pN/a/EuI36TgQjxm1upFSavbVRPC04h7UkafM8iGNvlwtPtMQwafR9yfvTiir+ewtnVaUN1UxIIQD4O5RYJiIOZoMdV3BCuyA1sweHuiaGWwOV/79k1mC/qIh/yo83yyCV+jXJ2Y9rbrzTbguCbTyo3CFChnH+Xof9bt4yBQDqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=QelRh/nz; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="QelRh/nz" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-661369ff30aso250287b3.2 for ; Fri, 26 Jul 2024 12:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022609; x=1722627409; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zpVclNxiHsXPViPqbtHO98PVPv965lezjoyg5+4dMsg=; b=QelRh/nzZuP3BGQ3C8f3bWmQ2QykSURFupo3TxTOCvIml5D7NGHofsRSPTcOOL64Q8 HcZ3fwIfxdk6WFqwoHOkIz++nWP7IhaL3aiO8b1nZJnn2tT3nX4ZeDoQ5syFO2YRrhhJ rbbL/p+l/PnpnmPboAdkazDk2nsFarXjOpd4R/BB6u2zGT1MgkHLB5efI3cyFtAtxFuf 68DqSmiUUCuques0HnAfWpU5FkmJA8IcfVBZGQO9xaC4GhSe0KQFCTvF/oSQftTNj7PK hw7bRJVKPX6ozE+y0cm8ZSyeFhD1Fxexg7eaFiAzBmE0OFjnY1V8vHYqa7bJXUiXRHcL k0cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022609; x=1722627409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zpVclNxiHsXPViPqbtHO98PVPv965lezjoyg5+4dMsg=; b=eX2fU7mhxySaHn4jrRw/iEzdsiTUeUkPhv7WZobjrrQMC31UL483DOKbz23r35i0w0 NCns+zm8SoNrBUS77F88roznJJjt0eEJKBXSSBGjALZpAHBwd3Q2nj8Q/hHn2UJ5ay25 3zLXRxgWwTDlXwb/0RLyeVE1AlrbJBvYmt59D73oS0Ezjxd80+HuJU/oTzSfApvvVeKG pS6ELCiciMo/rgL7LUe7Nl34Vs4oeMYox5dsWFVz3J+KZIgIUFHSuaq16c9gS+8Rm1yr P1O+h9KL/LE4kq3MXsFnFj36AmeXZ46ZTVV8kdUh9p/KSCZlGmOD94FTvXtQmq8SKKyG YXJQ== X-Gm-Message-State: AOJu0Yy1jJVJY5KytAd/Zn06iFXFrPibO48IUzk4/oVVzkJBldjyhK/U b2wOYz9BtvkSLozTOjIMwCmjA+R58E1UUnmtCxQIqZAG0cDQoUgSHV1rIUSRzmZnFOAMiDZVGBi B X-Google-Smtp-Source: AGHT+IGDO8w7NUq4vVxu89cHS1ZCir0PEL+TyYrjXZrTdTE9Gx8szrNDKELSQGJvzXsUdU1ECwTtJQ== X-Received: by 2002:a0d:e542:0:b0:64a:d5fd:f198 with SMTP id 00721157ae682-67a053e0cb3mr9741087b3.6.1722022608684; Fri, 26 Jul 2024 12:36:48 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756be88de8sm10025827b3.131.2024.07.26.12.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:48 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 11/46] btrfs: convert add_ra_bio_pages to use only folios Date: Fri, 26 Jul 2024 15:35:58 -0400 Message-ID: <929b6a9f0bc30212f5633a9f9a75aabb94b61cf5.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Willy is going to get rid of page->index, and add_ra_bio_pages uses page->index. Make his life easier by converting add_ra_bio_pages to use folios so that we are no longer using page->index. Signed-off-by: Josef Bacik --- fs/btrfs/compression.c | 62 ++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index a8e2c461aff7..832ab8984c41 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -420,7 +420,7 @@ static noinline int add_ra_bio_pages(struct inode *inode, u64 cur = cb->orig_bbio->file_offset + orig_bio->bi_iter.bi_size; u64 isize = i_size_read(inode); int ret; - struct page *page; + struct folio *folio; struct extent_map *em; struct address_space *mapping = inode->i_mapping; struct extent_map_tree *em_tree; @@ -453,9 +453,13 @@ static noinline int add_ra_bio_pages(struct inode *inode, if (pg_index > end_index) break; - page = xa_load(&mapping->i_pages, pg_index); - if (page && !xa_is_value(page)) { - sectors_missed += (PAGE_SIZE - offset_in_page(cur)) >> + folio = __filemap_get_folio(mapping, pg_index, 0, 0); + if (!IS_ERR(folio)) { + u64 folio_sz = folio_size(folio); + u64 offset = offset_in_folio(folio, cur); + + folio_put(folio); + sectors_missed += (folio_sz - offset) >> fs_info->sectorsize_bits; /* Beyond threshold, no need to continue */ @@ -466,35 +470,35 @@ static noinline int add_ra_bio_pages(struct inode *inode, * Jump to next page start as we already have page for * current offset. */ - cur = (pg_index << PAGE_SHIFT) + PAGE_SIZE; + cur += (folio_sz - offset); continue; } - page = __page_cache_alloc(mapping_gfp_constraint(mapping, - ~__GFP_FS)); - if (!page) + folio = filemap_alloc_folio(mapping_gfp_constraint(mapping, + ~__GFP_FS), 0); + if (!folio) break; - if (add_to_page_cache_lru(page, mapping, pg_index, GFP_NOFS)) { - put_page(page); + if (filemap_add_folio(mapping, folio, pg_index, GFP_NOFS)) { /* There is already a page, skip to page end */ - cur = (pg_index << PAGE_SHIFT) + PAGE_SIZE; + cur += folio_size(folio); + folio_put(folio); continue; } - if (!*memstall && PageWorkingset(page)) { + if (!*memstall && folio_test_workingset(folio)) { psi_memstall_enter(pflags); *memstall = 1; } - ret = set_page_extent_mapped(page); + ret = set_folio_extent_mapped(folio); if (ret < 0) { - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); break; } - page_end = (pg_index << PAGE_SHIFT) + PAGE_SIZE - 1; + page_end = (pg_index << PAGE_SHIFT) + folio_size(folio) - 1; lock_extent(tree, cur, page_end, NULL); read_lock(&em_tree->lock); em = lookup_extent_mapping(em_tree, cur, page_end + 1 - cur); @@ -511,28 +515,28 @@ static noinline int add_ra_bio_pages(struct inode *inode, orig_bio->bi_iter.bi_sector) { free_extent_map(em); unlock_extent(tree, cur, page_end, NULL); - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); break; } add_size = min(em->start + em->len, page_end + 1) - cur; free_extent_map(em); - if (page->index == end_index) { - size_t zero_offset = offset_in_page(isize); + if (folio->index == end_index) { + size_t zero_offset = offset_in_folio(folio, isize); if (zero_offset) { int zeros; - zeros = PAGE_SIZE - zero_offset; - memzero_page(page, zero_offset, zeros); + zeros = folio_size(folio) - zero_offset; + folio_zero_range(folio, zero_offset, zeros); } } - ret = bio_add_page(orig_bio, page, add_size, offset_in_page(cur)); - if (ret != add_size) { + if (!bio_add_folio(orig_bio, folio, add_size, + offset_in_folio(folio, cur))) { unlock_extent(tree, cur, page_end, NULL); - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); break; } /* @@ -541,9 +545,9 @@ static noinline int add_ra_bio_pages(struct inode *inode, * subpage::readers and to unlock the page. */ if (fs_info->sectorsize < PAGE_SIZE) - btrfs_subpage_start_reader(fs_info, page_folio(page), - cur, add_size); - put_page(page); + btrfs_subpage_start_reader(fs_info, folio, cur, + add_size); + folio_put(folio); cur += add_size; } return 0; From patchwork Fri Jul 26 19:35:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743080 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 084E514900B for ; Fri, 26 Jul 2024 19:36:50 +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=1722022612; cv=none; b=S5vCJxdeHvXrh2DtChdXtkbY1fMyYNE3C0siHRG9LRcb7L0+04EBCB8pUfQ2XQ1KALb7IT5No7QNSu8EUAQA4sVjw10yCP2/GDbYuDtbxSxpFNb0I9134dqFutOjz4g8p06yizEd/XitunE87gsc9BdjWQWoXDLdK0/7oblOcf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022612; c=relaxed/simple; bh=M5FjRmgf3k2EgTXWw6Xz2xBa3uL2QyAioHcdq42KMwk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cpseBG164EP8dsHY9PGKeLvn08RyRJUX5zhUo34I18pjj3J5KbHtHMgJEhbauNxrXMh2blI3/XnlaGVrg8k3FrIblflZFN3A/aDMORvRaye6kXbCwYNrZLv8nrTwKVHcb95HK3ymkCPA28jjTScu9XLW6ORXc5DsJw+gMP2mJUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=UrmzcRKA; arc=none smtp.client-ip=209.85.128.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="UrmzcRKA" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-66599ca3470so396657b3.2 for ; Fri, 26 Jul 2024 12:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022610; x=1722627410; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JiGlCVNajVo50PhEvdILpXRpkD3zKnXubK8bhIL4PN0=; b=UrmzcRKAh+7xb7cS0dAaR+5YoJZZUiXKEFIvDBYsQAINeHR99bGkWa391MvPk+KlpH e4SPz+Kqw67RoDXAkH+JQHztsMu/4wy9vr4D1kA3STb1Qj3XtzhgknmtHtmX1/HTYsJE Cl2D9Pz1NW1CqxSZ2ijU3qr4XncRm5hKlda9hM8ZLsjsGLnlLIYXog1L1KxiT0xFFK2I 8EfX1balRejMU7cB+hjdnnQkh5zqtNBrNj6jVLzxR5NRZp6oW9t2yA9stdlMn9Tovsx4 4Rw54zPTkZ1WesqRxnUvYn6QudyQtTLzTczRXOF8K/wSsWZyC/ed/xEle1wvjw9N93uq VlNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022610; x=1722627410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JiGlCVNajVo50PhEvdILpXRpkD3zKnXubK8bhIL4PN0=; b=GNv1111oJJrpYEvtxoCr5bKx+oV81MmTXb75EqIupF2Ad7VeCR4z4HW28VgJiAv78m KNKnWEXYu84jXcDX62PkmH6h0i+H54FEcy2VVIJALejcJCLC8msZkjtcrLZYjqlMYOdR sx4dtpUKWZ5N1ANWWARvbkCjop9iYfCyTbVqfOBMbLl76ySgYY3mJsT3w9wdj9kfRe8J 9v4aqVyk+2ieZzvjUtKj3YGojdlbbnHtKyf88fPU7O0Cf1hptW/DxBS+ac5/Kx9uWfrH E0eF+wfyMEdhXgSRqU2/NkTC+wcgv1+uE5Dr0ZxOj+g2MKlywy32YCJkTKlzyCL+rMMr +38w== X-Gm-Message-State: AOJu0YzS3Lg6hF945h3F5w7oZlcMpMZu7CaRv6vwAH7RbMfrMxyM8Tbg GfpVJfKOF6l+KpnLu+nqtMHpfzD/LdmESmaid+S8soXYmey8v0D9+n7PigfDuuDPzpIRM3QLd3H + X-Google-Smtp-Source: AGHT+IEh39rjWyNvFe/Gws8ZD1J5phZkO49/PLAp2nncX+x3qAdL8y3smsWB/SLu+nxOW/PFeXCRyA== X-Received: by 2002:a81:5c04:0:b0:62f:9e2d:3e5d with SMTP id 00721157ae682-67a0a8f2addmr9440207b3.43.1722022609755; Fri, 26 Jul 2024 12:36:49 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756bab3242sm9813777b3.109.2024.07.26.12.36.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:49 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 12/46] btrfs: utilize folio more in btrfs_page_mkwrite Date: Fri, 26 Jul 2024 15:35:59 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We already have a folio that we're using in btrfs_page_mkwrite, update the rest of the function to use folio everywhere else. This will make it easier on Willy when he drops page->index. Signed-off-by: Josef Bacik --- fs/btrfs/file.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 21381de906f6..cac177c5622d 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1901,8 +1901,8 @@ static vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) reserved_space = PAGE_SIZE; sb_start_pagefault(inode->i_sb); - page_start = page_offset(page); - page_end = page_start + PAGE_SIZE - 1; + page_start = folio_pos(folio); + page_end = page_start + folio_size(folio) - 1; end = page_end; /* @@ -1930,18 +1930,18 @@ static vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) ret = VM_FAULT_NOPAGE; again: down_read(&BTRFS_I(inode)->i_mmap_lock); - lock_page(page); + folio_lock(folio); size = i_size_read(inode); - if ((page->mapping != inode->i_mapping) || + if ((folio->mapping != inode->i_mapping) || (page_start >= size)) { /* Page got truncated out from underneath us. */ goto out_unlock; } - wait_on_page_writeback(page); + folio_wait_writeback(folio); lock_extent(io_tree, page_start, page_end, &cached_state); - ret2 = set_page_extent_mapped(page); + ret2 = set_folio_extent_mapped(folio); if (ret2 < 0) { ret = vmf_error(ret2); unlock_extent(io_tree, page_start, page_end, &cached_state); @@ -1955,14 +1955,14 @@ static vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) ordered = btrfs_lookup_ordered_range(BTRFS_I(inode), page_start, PAGE_SIZE); if (ordered) { unlock_extent(io_tree, page_start, page_end, &cached_state); - unlock_page(page); + folio_unlock(folio); up_read(&BTRFS_I(inode)->i_mmap_lock); btrfs_start_ordered_extent(ordered); btrfs_put_ordered_extent(ordered); goto again; } - if (page->index == ((size - 1) >> PAGE_SHIFT)) { + if (folio->index == ((size - 1) >> PAGE_SHIFT)) { reserved_space = round_up(size - page_start, fs_info->sectorsize); if (reserved_space < PAGE_SIZE) { end = page_start + reserved_space - 1; @@ -1992,13 +1992,13 @@ static vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) } /* Page is wholly or partially inside EOF. */ - if (page_start + PAGE_SIZE > size) - zero_start = offset_in_page(size); + if (page_start + folio_size(folio) > size) + zero_start = offset_in_folio(folio, size); else zero_start = PAGE_SIZE; if (zero_start != PAGE_SIZE) - memzero_page(page, zero_start, PAGE_SIZE - zero_start); + folio_zero_range(folio, zero_start, folio_size(folio) - zero_start); btrfs_folio_clear_checked(fs_info, folio, page_start, PAGE_SIZE); btrfs_folio_set_dirty(fs_info, folio, page_start, end + 1 - page_start); @@ -2015,7 +2015,7 @@ static vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) return VM_FAULT_LOCKED; out_unlock: - unlock_page(page); + folio_unlock(folio); up_read(&BTRFS_I(inode)->i_mmap_lock); out: btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE); From patchwork Fri Jul 26 19:36:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743081 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 070711494C4 for ; Fri, 26 Jul 2024 19:36:51 +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=1722022613; cv=none; b=JNyfBoaE3I9oH2cRu/Xs2GinUSjrL+KRJtGel6EiNg7QvjsiwaRwGY6uKuH4pPSV6MPNheNlpywrsAB30h4b/OMIG0Tpr/cDxfAB92RloejkEt2Flcr84C8UkR5BX6R5vIFd+G/0QxmAHYSkRHNZK4PKc2RvwNVpOltqTd5QKfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022613; c=relaxed/simple; bh=J7BBIGhhm2FS8UFEmQBi7T+yd9UdETAZk7vQWLqu3I8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dXWL82gK5zy1IO/PvgkEKZ3s9mIhpVeKH+xUznZAy+rwwa0SAXm8XtGkZukLppkGKHqxd221U2k0mSlCw9VGjL/e7Vu648euy9Aw/rGTMn51QzFkDPKkHW4VshXFPTpldzVcu00TYXdWLZ82UWxUOynjOOHc4PWagawROOpmWmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=jng4wTTn; arc=none smtp.client-ip=209.85.128.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="jng4wTTn" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-66acac24443so474997b3.1 for ; Fri, 26 Jul 2024 12:36:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022611; x=1722627411; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4LnGUFZUUgHRmnS2zRm+HCi7okNv00BI48+/c5ZwGSU=; b=jng4wTTnS5HpRhsFdJR6FcUoBNc+adNIzkSQ/NNRvnCVuO+WFnRxl+FC3HQtvurAAw 5Wli/f/cVq5bBo03loK0RJXkBM4/aMrowdwN6U2EfVsxMBoD5h+5Dif3WCCMIqESz3kJ ExymX30AZAQApuoAgvE8i9Pthls80AKyq64WWrHFNFqdyWsRPCt1iQSuWHYz5tKXDbGJ 6Bwct7GMxRKaw+jZwIEXVDdWLoi1uKJk9mMKjoUmPeueEod80uNuK1ugRGOP49WyQ07Y CrPLeGckmLKr+gxscX//jGXqmGuYOG6lQumPGuL3DHqkloJik3Z+k2RD9bHXRGkvPgLM p7kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022611; x=1722627411; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4LnGUFZUUgHRmnS2zRm+HCi7okNv00BI48+/c5ZwGSU=; b=VdicpnBE4kTzsIknWgyPBC4i54XGrBcQxiMeozWoMVAwHNZ5L+dXVVWOyMSb6rHGWX Y/+vZwSTmd8bjtGcYth/yLUxhsTaIhxFc8ILvCDjHbOH12Gur6uaco+FLLvPEmXQf+NX d790jPwsn645Ggy3XZYQi4UGjS76+7GLJ6mH1OszBCayxw3CcquTD9bYhGDcjeBDiHEq lBURlUORIiMtPsHu5Cbe3EgRPpqGOVGVh02Y1iXAsU8mFU6XinGY4zhMj7Xjxxm3G0Yg uCwQF3il3eyjbV1FaR6502C6fH1s+7jh4obdTHBYq5vtYflZCfpP3dWt4hd0RHoQSHlK +zCQ== X-Gm-Message-State: AOJu0Ywyntqjg3Aigx+RQyNhzGQ30n9yCZv1KcgfgG5rqZdNwtdUp57w ZRNcUVj80HRWNRMijPfbsfiTOWiZGBgbZ1jIMAGwwivYDtZ1yMlv6YKQ3zUI1W2J4h4UV8HhBrE J X-Google-Smtp-Source: AGHT+IFmt/O9WZX/lFDiuezmNO3j0ssPcWjg6Um/H7DPMD1gXhdy7CobV013iiBIWTSC4eFcenwm+A== X-Received: by 2002:a0d:f3c6:0:b0:627:24d0:5037 with SMTP id 00721157ae682-679ffbfc4a8mr10645207b3.0.1722022610994; Fri, 26 Jul 2024 12:36:50 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756795e992sm9977077b3.46.2024.07.26.12.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:50 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 13/46] btrfs: convert can_finish_ordered_extent to use a folio Date: Fri, 26 Jul 2024 15:36:00 -0400 Message-ID: <707dc843b9812f05f89071714bcf881e24d38bff.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Pass in a folio instead, and use a folio instead of a page. Signed-off-by: Josef Bacik --- fs/btrfs/ordered-data.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 82a68394a89c..760a37512c7e 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -332,7 +332,7 @@ static void finish_ordered_fn(struct btrfs_work *work) } static bool can_finish_ordered_extent(struct btrfs_ordered_extent *ordered, - struct page *page, u64 file_offset, + struct folio *folio, u64 file_offset, u64 len, bool uptodate) { struct btrfs_inode *inode = ordered->inode; @@ -340,10 +340,10 @@ static bool can_finish_ordered_extent(struct btrfs_ordered_extent *ordered, lockdep_assert_held(&inode->ordered_tree_lock); - if (page) { - ASSERT(page->mapping); - ASSERT(page_offset(page) <= file_offset); - ASSERT(file_offset + len <= page_offset(page) + PAGE_SIZE); + if (folio) { + ASSERT(folio->mapping); + ASSERT(folio_pos(folio) <= file_offset); + ASSERT(file_offset + len <= folio_pos(folio) + folio_size(folio)); /* * Ordered (Private2) bit indicates whether we still have @@ -351,10 +351,9 @@ static bool can_finish_ordered_extent(struct btrfs_ordered_extent *ordered, * * If there's no such bit, we need to skip to next range. */ - if (!btrfs_folio_test_ordered(fs_info, page_folio(page), - file_offset, len)) + if (!btrfs_folio_test_ordered(fs_info, folio, file_offset, len)) return false; - btrfs_folio_clear_ordered(fs_info, page_folio(page), file_offset, len); + btrfs_folio_clear_ordered(fs_info, folio, file_offset, len); } /* Now we're fine to update the accounting. */ @@ -408,7 +407,8 @@ void btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered, trace_btrfs_finish_ordered_extent(inode, file_offset, len, uptodate); spin_lock_irqsave(&inode->ordered_tree_lock, flags); - ret = can_finish_ordered_extent(ordered, page, file_offset, len, uptodate); + ret = can_finish_ordered_extent(ordered, page_folio(page), file_offset, + len, uptodate); spin_unlock_irqrestore(&inode->ordered_tree_lock, flags); /* @@ -524,7 +524,8 @@ void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode, ASSERT(end + 1 - cur < U32_MAX); len = end + 1 - cur; - if (can_finish_ordered_extent(entry, page, cur, len, uptodate)) { + if (can_finish_ordered_extent(entry, page_folio(page), cur, len, + uptodate)) { spin_unlock_irqrestore(&inode->ordered_tree_lock, flags); btrfs_queue_ordered_fn(entry); spin_lock_irqsave(&inode->ordered_tree_lock, flags); From patchwork Fri Jul 26 19:36:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743082 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 1FA26149C4C for ; Fri, 26 Jul 2024 19:36:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022614; cv=none; b=XUdhaQgc1uBNWzMArpIPR9bQaDzCblp6XbC9vmeOELW/XO9O2nnbcV+h2vogFK4ENHMzOM+GSitio84dGyUW4+IoLVhFpAy0yvnB/NccJUqUfGEfv4ZgTLWXX1dfU3rgBBiYIYJ30j2DgtTjTcTtubvRKSw4bNrl8Kp3ppa+9l0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022614; c=relaxed/simple; bh=udp684RkXNYbhUh8bSqv/xFVw2PxqgIDsDcnYs2xmkM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tOt6C5EggRqhVHNOlJOVdlhKTF8+xqWi+9UaONxVmm/NYrQx5S4HE/MW80FOcGH/nhXuhLh0HtL5ZWA/CKNqrAKTsVmY+RFgxX8nAR2hTK9dgFIz4W60xVASBgZcEb4hM7uNIgsBTe8pNSxxbhOM87muQ0E8aZ2MwaepiIwsMfM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=f8yjYik1; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="f8yjYik1" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-65f7bd30546so308177b3.1 for ; Fri, 26 Jul 2024 12:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022612; x=1722627412; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=U89LoR7x+SU8mlCoGzs9YXLEUTi2x66vs1Payvo+bvo=; b=f8yjYik1jW9kPa1zlsZ6/U+Xa/k4nP948CkkUcy8ugSW4ZOQpp2372okrjuWB97v2I lmVYrL19XM4CdPk3W+C5T8unmvXTIGeLiliSa6EdYiSQSWON/OlkeuLj/gsa/t3uXme8 Nro0VdXYCIBCPdGSHYA1MxpsktkZbn16yHk/yS3+gvyq3nQQYK15TfugAwt2bAYNcUei TJRol0+Xl4o5v21VFUQc0c4DgdAzo/srkmfjC0MPTtqDMcSfuFre+4Do5s5R8HA8G0ZQ kv1Rjru/DeK4pkvfHXFswc1KvetnL+Onw3/959u2QaSW5c6lrTsGJCcbryiZuRFzehm7 mL1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022612; x=1722627412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U89LoR7x+SU8mlCoGzs9YXLEUTi2x66vs1Payvo+bvo=; b=dBZPkt9hE62HtfH8A343d55LcmSzDyFn+9BVErNR35YUMBhWl8qIVizdY1Y65TW2xx rHcy/lKJf6CXKLoa3hGcH3JQ5gJx64YC9iCk83wEgLUoMcwBw5ueytsvvJxF0mw4+xFr ZDjqgpeu2Rz3TAGEacadZ4mx9Zitjq8SMBTSWUu1L0jt2l4VdVzHUgGGLgTiBIKe/mWZ 5u1SVTpzsJXeQWNstXJlPBgJ01PdvSg2hPc9ex2L6l75aU0LWWSFn3LaaJvsss2fGqUS vf/Ask8s8k6P1YcmLxXKNT5nDb36STWQuy8XitiGSGBkhts++p6EkMnluoZD1sL1Qplb eTfg== X-Gm-Message-State: AOJu0YwUSDCD7Cr+QQbBrD2bLZgyD7RH4v8+uU60MqYBKwSBq4ZyBY0H D6/4czzHZop3Y3/ZhH9d1kl+0nnpCLp/Z6ftvh/ZaaiO+ZipR9/3O6J6ELxOMB5J5IE5j14nIZZ 8 X-Google-Smtp-Source: AGHT+IEAbTA/shjtuVGRQt6h5pne8p5dusvScColQPXgVjW4WXRfok7P7iaYyOfGm0DB49nmwiThfQ== X-Received: by 2002:a05:690c:ecb:b0:65f:cdb7:46a7 with SMTP id 00721157ae682-67a2dcf7ad1mr6690947b3.22.1722022611959; Fri, 26 Jul 2024 12:36:51 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67566dd91ecsm10014987b3.17.2024.07.26.12.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:51 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 14/46] btrfs: convert btrfs_finish_ordered_extent to take a folio Date: Fri, 26 Jul 2024 15:36:01 -0400 Message-ID: <390ffab7d7ed61dbee07947874ab11f1d5e1d155.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The callers and callee's of this now all use folios, update it to take a folio as well. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 4 ++-- fs/btrfs/ordered-data.c | 6 +++--- fs/btrfs/ordered-data.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index da60ec1e866a..58ff09368eb9 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -472,8 +472,8 @@ static void end_bbio_data_write(struct btrfs_bio *bbio) "incomplete page write with offset %zu and length %zu", fi.offset, fi.length); - btrfs_finish_ordered_extent(bbio->ordered, - folio_page(folio, 0), start, len, !error); + btrfs_finish_ordered_extent(bbio->ordered, folio, start, len, + !error); if (error) mapping_set_error(folio->mapping, error); btrfs_folio_clear_writeback(fs_info, folio, start, len); diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 760a37512c7e..e97747956040 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -397,7 +397,7 @@ static void btrfs_queue_ordered_fn(struct btrfs_ordered_extent *ordered) } void btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered, - struct page *page, u64 file_offset, u64 len, + struct folio *folio, u64 file_offset, u64 len, bool uptodate) { struct btrfs_inode *inode = ordered->inode; @@ -407,8 +407,8 @@ void btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered, trace_btrfs_finish_ordered_extent(inode, file_offset, len, uptodate); spin_lock_irqsave(&inode->ordered_tree_lock, flags); - ret = can_finish_ordered_extent(ordered, page_folio(page), file_offset, - len, uptodate); + ret = can_finish_ordered_extent(ordered, folio, file_offset, len, + uptodate); spin_unlock_irqrestore(&inode->ordered_tree_lock, flags); /* diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index 51b9e81726e2..90c1c3c51ae5 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -163,7 +163,7 @@ void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry); void btrfs_remove_ordered_extent(struct btrfs_inode *btrfs_inode, struct btrfs_ordered_extent *entry); void btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered, - struct page *page, u64 file_offset, u64 len, + struct folio *folio, u64 file_offset, u64 len, bool uptodate); void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode, struct page *page, u64 file_offset, From patchwork Fri Jul 26 19:36:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743083 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 2DD22149C6C for ; Fri, 26 Jul 2024 19:36:54 +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=1722022615; cv=none; b=qRTHexOMJiDiU+OioZMdRVVqbEDcojpu0S/+gbsrjbg0VnKYcmZb4CvE3rqj4CRogXFhdlMPVK9OFuwWfY+Oo6xG1/z+2a64jgLvcOnLol2+WvtIIEobatCRW+HjZRTHAJuUT+Mrm6adsEC/606sfob/wazRnD9ZOx1CrcM0Tno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022615; c=relaxed/simple; bh=VDAooYh9HjQiFLV6TCEASkVboELzoqk0Tb5yUcdzMkk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I92iEMzLr6u2nxg56wBBlKPnzqYH8AzzGZqRlM+ZxgqjPjQsm6F0WxuRKMuWFlOOo4/uzZ6eBX7NEDY0n7lhyDOh4u2C+2IjsFzTiYp/96yE+WsQtR/5nQWmNV0aHsKrlQG1g3NZEePpbxAekCzlw5KRWR7HpxtkiTxr5hb+Atg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=pit8l/zx; arc=none smtp.client-ip=209.85.128.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="pit8l/zx" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-64b29539d86so333327b3.2 for ; Fri, 26 Jul 2024 12:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022613; x=1722627413; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9uqAo0sphthKfqbM6Qkv/CNluSZdkXHFpbAPOmW6TFg=; b=pit8l/zxoCxnSFezlWzpV9UbODLOYZDt3MsUcGqbVU8f6DZZ3OFS2uGz5jVhUH0FiI oRTw+rdyxycImieaI8dL9afWpeB+v2doknBTd1+skfMq0iNiyHZoinLGb3SgcJxc+0sP JK8hgStVu2tZ80f5XbqCf8Vv3AzufsqyRWQBMcBzo5l9Z7g4c90vgEcqqYtaYesrNZn/ flVz++TskfrreXIQ7NvStcNrCD6G/FikcUede92ZZfqNVpSTfdihIqG3QGRLv+XlnzkT 03gCWfqi+3W5VyJVhQawBtZfncGWaoK8mvBY5MN56bDsP61dy7CozT8IWYhrYmQgpOs0 P+Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022613; x=1722627413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9uqAo0sphthKfqbM6Qkv/CNluSZdkXHFpbAPOmW6TFg=; b=IS3b5OOLIedPnMS6KZY1KJfOcU7w1qdy8CqUxhYM4UAOOhHXP8lrhZs8wAmWWctkiA Bgo/e964iF0oDy29Kd7LTfMjNa5kgXnFT+jU9M5FmCk+B1N5VTTd++L36NEl8KMaHUpb PVDObtLJOjjF9RogPoTVogdAKrsApIYpRphFjPSEgTE9df9rTk3vDpg6FPmpko+Xaylc 0+CpQi8OmzwkESFOktpyo9yrGf5VhSXsv6xo/P/e8mbcQ5SJXqtIzMDdkCt/Xyp69ViA kvtywQyq3yuKxwe9JXrDlutWiC/KrkFwbTXmeacgDkEum0X0+7RbfQ0DH6cBBq7aWkPD pq4Q== X-Gm-Message-State: AOJu0Yz7I/LPVrsYuN1XKCD9ClehLpnDwQ+ZNWGwjuAmFgielxLbhbn4 kjvnhPltXLfWF0ZsrPULDVqQZ+UMCPQDXwTCGfgVDqn8vBO8OrlPyYer/c02yDZj3eJvQDvuGnU W X-Google-Smtp-Source: AGHT+IFamfSyok7zp3qArQGV2boXonqTd6WsfRGaQAr81rRnhHPd/FxVI7Qo7z3IFclXp437Az7ejA== X-Received: by 2002:a0d:f444:0:b0:653:ffe7:d641 with SMTP id 00721157ae682-67a0afb6583mr8384287b3.45.1722022613003; Fri, 26 Jul 2024 12:36:53 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756b9be42fsm9744097b3.105.2024.07.26.12.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:52 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 15/46] btrfs: convert btrfs_mark_ordered_io_finished to take a folio Date: Fri, 26 Jul 2024 15:36:02 -0400 Message-ID: <903924f0155d9652b950b650a69f634b9341aa35.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We only need a folio now, make it take a folio as an argument and update all of the callers. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 8 ++++---- fs/btrfs/inode.c | 7 ++++--- fs/btrfs/ordered-data.c | 9 ++++----- fs/btrfs/ordered-data.h | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 58ff09368eb9..56bf87ac5f6c 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1428,8 +1428,8 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, u32 iosize; if (cur >= i_size) { - btrfs_mark_ordered_io_finished(inode, &folio->page, cur, - len, true); + btrfs_mark_ordered_io_finished(inode, folio, cur, len, + true); /* * This range is beyond i_size, thus we don't need to * bother writing back. @@ -1569,7 +1569,7 @@ static int __extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ct folio_end_writeback(folio); } if (ret) { - btrfs_mark_ordered_io_finished(BTRFS_I(inode), &folio->page, + btrfs_mark_ordered_io_finished(BTRFS_I(inode), folio, page_start, PAGE_SIZE, !ret); mapping_set_error(folio->mapping, ret); } @@ -2331,7 +2331,7 @@ void extent_write_locked_range(struct inode *inode, const struct page *locked_pa btrfs_folio_clear_writeback(fs_info, folio, cur, cur_len); } if (ret) { - btrfs_mark_ordered_io_finished(BTRFS_I(inode), &folio->page, + btrfs_mark_ordered_io_finished(BTRFS_I(inode), folio, cur, cur_len, !ret); mapping_set_error(mapping, ret); } diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 26dc2c3ac903..a8744d2c6a97 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1144,7 +1144,8 @@ static void submit_uncompressed_range(struct btrfs_inode *inode, set_page_writeback(locked_page); end_page_writeback(locked_page); - btrfs_mark_ordered_io_finished(inode, locked_page, + btrfs_mark_ordered_io_finished(inode, + page_folio(locked_page), page_start, PAGE_SIZE, !ret); mapping_set_error(locked_page->mapping, ret); @@ -2802,8 +2803,8 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) * to reflect the errors and clean the page. */ mapping_set_error(page->mapping, ret); - btrfs_mark_ordered_io_finished(inode, page, page_start, - PAGE_SIZE, !ret); + btrfs_mark_ordered_io_finished(inode, page_folio(page), + page_start, PAGE_SIZE, !ret); clear_page_dirty_for_io(page); } btrfs_folio_clear_checked(fs_info, page_folio(page), page_start, PAGE_SIZE); diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index e97747956040..eb9b32ffbc0c 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -449,8 +449,8 @@ void btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered, /* * Mark all ordered extents io inside the specified range finished. * - * @page: The involved page for the operation. - * For uncompressed buffered IO, the page status also needs to be + * @folio: The involved folio for the operation. + * For uncompressed buffered IO, the folio status also needs to be * updated to indicate whether the pending ordered io is finished. * Can be NULL for direct IO and compressed write. * For these cases, callers are ensured they won't execute the @@ -460,7 +460,7 @@ void btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered, * extent(s) covering it. */ void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode, - struct page *page, u64 file_offset, + struct folio *folio, u64 file_offset, u64 num_bytes, bool uptodate) { struct rb_node *node; @@ -524,8 +524,7 @@ void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode, ASSERT(end + 1 - cur < U32_MAX); len = end + 1 - cur; - if (can_finish_ordered_extent(entry, page_folio(page), cur, len, - uptodate)) { + if (can_finish_ordered_extent(entry, folio, cur, len, uptodate)) { spin_unlock_irqrestore(&inode->ordered_tree_lock, flags); btrfs_queue_ordered_fn(entry); spin_lock_irqsave(&inode->ordered_tree_lock, flags); diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index 90c1c3c51ae5..4e152736d06c 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -166,8 +166,8 @@ void btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered, struct folio *folio, u64 file_offset, u64 len, bool uptodate); void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode, - struct page *page, u64 file_offset, - u64 num_bytes, bool uptodate); + struct folio *folio, u64 file_offset, + u64 num_bytes, bool uptodate); bool btrfs_dec_test_ordered_pending(struct btrfs_inode *inode, struct btrfs_ordered_extent **cached, u64 file_offset, u64 io_size); From patchwork Fri Jul 26 19:36:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743084 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 47218149C79 for ; Fri, 26 Jul 2024 19:36:55 +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=1722022616; cv=none; b=U3KCYJdgvFmy82s+5LlTnqlPWWvf20FJ337XDSqVtgUDttyPgNpSiteUBY4KLmXCGZF3ro0LSG4JxWScxdk0e6zUceS0GoZeHiEaNf8lxBnx4xTP9dwpatR+uVsI56E3ezf9bPRsr52QG3j4IDN86BngFfIdl7QmrU1DQYtf28o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022616; c=relaxed/simple; bh=z0J9OLU/Qf9HSdUgztK/1/M8Ro0zZ+5iF3X8mvsFDlE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ndmQXftUHoojRKtHnOTi0tJT3J4kB1fXYdXJs3PH+9+MFieTLD+2u6K6bbs5FkMht1eC3yRdfoc8ueb5BcAsS1p1iOg80IDm01A+QSmNbSQpnbNNU5JwCVEoYGAiNKAvV7bCpzNzgaLaH4W+WRJFa/aHi2IiS604X/3pq3GDW4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=KodP7esd; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="KodP7esd" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-66526e430e0so373817b3.2 for ; Fri, 26 Jul 2024 12:36:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022614; x=1722627414; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mryCiiI3DzqdyEiwL6B0Sb6EH1sXDmGlzAexz+XtQuQ=; b=KodP7esd4MwhiEv849MN0qSCFINePf5ojjg4bgt0JjssPwagQT4blKvgylmnwCE7OL fXFHJ+972bcxHRR3lG0vmj9PlAA6zw5dXcWJNopt3Kacui80ew+L+KPPKbanONtDwO+q jiYbPDLMSnAcjqvuSUG0iUjP2AdDOKlvjlmiTQ4x4viUO2GPAMlabCWxWh3c0nRy67zv dYII0gTCZMMgNDb1buj5JmCkpHkNuL0RpjHiYJm6U4at/kPG6fKSIWM1KKnmhspFvR85 1GMcYr3ZG6RpqSZJjEbPljf1N5olOrQ0DFJKqbx5dG7pgA/o0KTCHAuYgrPBwnLi+lYd RfxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022614; x=1722627414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mryCiiI3DzqdyEiwL6B0Sb6EH1sXDmGlzAexz+XtQuQ=; b=BAZ1MiWwXU3jwZndcI9z8WlfyUNTcelbcBDtOIKs7Q5eo90+L1UIuGUUKOzK4SJ1PF NdPm6aTHNxTFIQzdU1WFNC6/vDM1WZvQ7aMYHz7ayPq0A7aI4xzbNx+xEXYa5tsh+eLA 00SO8w8sxjMR6YVSI+YhdT+YQAB5jVczA81J9a7FJ98ZrtbX9RxPiFmjKH24UljTDpM5 2ICS+Mx6ULK5Kua4rqZDGSnnU5g2ecZ9c56xpkjcMSttMbK68VuhRBG2UICAZO4fVKtj 6gZBs9qBYxXwkDuG+pKBDWO6A2ZC88Ar1zuOiz2gOxNNUDw3tHNSUVY9CrLhfZPOE6WG Iy9Q== X-Gm-Message-State: AOJu0Yy5eBeg44Qtaj44ZMrCFSGqfPtm2hgTA4lHXXiCMXi8iWX5xuJ1 29XuLYVGLmWU7sSctVWbLrp8iKGOm0O69/DCQolElE8Pyl6IW1iEt93urW27GD9/CZSRYuDEHxQ w X-Google-Smtp-Source: AGHT+IHJUkgmwGaAPR1Unr4ITZeeDTOAXd9Pz7JauekhKJAAfzaz2oSiTF4TO5lxpvEXD1D1z26/FA== X-Received: by 2002:a0d:d206:0:b0:64b:8e82:1f9 with SMTP id 00721157ae682-67a0644372amr9395887b3.18.1722022614181; Fri, 26 Jul 2024 12:36:54 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756b024d7bsm10044287b3.83.2024.07.26.12.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:53 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 16/46] btrfs: convert writepage_delalloc to take a folio Date: Fri, 26 Jul 2024 15:36:03 -0400 Message-ID: <0d68fc276f4b7a6983008a8e4ee4cd7fe4491a4d.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We already use a folio heavily in this function, pass the folio in directly and use it everywhere, only passing the page down to functions that do not take a folio yet. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 56bf87ac5f6c..382558fe1032 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1188,13 +1188,13 @@ int btrfs_read_folio(struct file *file, struct folio *folio) * This returns < 0 if there were errors (page still locked) */ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, - struct page *page, struct writeback_control *wbc) + struct folio *folio, + struct writeback_control *wbc) { struct btrfs_fs_info *fs_info = inode_to_fs_info(&inode->vfs_inode); - struct folio *folio = page_folio(page); - const bool is_subpage = btrfs_is_subpage(fs_info, page->mapping); - const u64 page_start = page_offset(page); - const u64 page_end = page_start + PAGE_SIZE - 1; + const bool is_subpage = btrfs_is_subpage(fs_info, folio->mapping); + const u64 page_start = folio_pos(folio); + const u64 page_end = page_start + folio_size(folio) - 1; /* * Save the last found delalloc end. As the delalloc end can go beyond * page boundary, thus we cannot rely on subpage bitmap to locate the @@ -1206,10 +1206,10 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, u64 delalloc_to_write = 0; int ret = 0; - /* Lock all (subpage) delalloc ranges inside the page first. */ + /* Lock all (subpage) delalloc ranges inside the folio first. */ while (delalloc_start < page_end) { delalloc_end = page_end; - if (!find_lock_delalloc_range(&inode->vfs_inode, page, + if (!find_lock_delalloc_range(&inode->vfs_inode, &folio->page, &delalloc_start, &delalloc_end)) { delalloc_start = delalloc_end + 1; continue; @@ -1234,7 +1234,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, if (!is_subpage) { /* * For non-subpage case, the found delalloc range must - * cover this page and there must be only one locked + * cover this folio and there must be only one locked * delalloc range. */ found_start = page_start; @@ -1248,7 +1248,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, break; /* * The subpage range covers the last sector, the delalloc range may - * end beyond the page boundary, use the saved delalloc_end + * end beyond the folio boundary, use the saved delalloc_end * instead. */ if (found_start + found_len >= page_end) @@ -1256,7 +1256,8 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, if (ret >= 0) { /* No errors hit so far, run the current delalloc range. */ - ret = btrfs_run_delalloc_range(inode, page, found_start, + ret = btrfs_run_delalloc_range(inode, &folio->page, + found_start, found_start + found_len - 1, wbc); } else { @@ -1266,15 +1267,16 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, */ unlock_extent(&inode->io_tree, found_start, found_start + found_len - 1, NULL); - __unlock_for_delalloc(&inode->vfs_inode, page, found_start, + __unlock_for_delalloc(&inode->vfs_inode, &folio->page, + found_start, found_start + found_len - 1); } /* * We can hit btrfs_run_delalloc_range() with >0 return value. * - * This happens when either the IO is already done and page - * unlocked (inline) or the IO submission and page unlock would + * This happens when either the IO is already done and folio + * unlocked (inline) or the IO submission and folio unlock would * be handled as async (compression). * * Inline is only possible for regular sectorsize for now. @@ -1282,14 +1284,14 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, * Compression is possible for both subpage and regular cases, * but even for subpage compression only happens for page aligned * range, thus the found delalloc range must go beyond current - * page. + * folio. */ if (ret > 0) ASSERT(!is_subpage || found_start + found_len >= page_end); /* - * Above btrfs_run_delalloc_range() may have unlocked the page, - * thus for the last range, we cannot touch the page anymore. + * Above btrfs_run_delalloc_range() may have unlocked the folio, + * thus for the last range, we cannot touch the folio anymore. */ if (found_start + found_len >= last_delalloc_end + 1) break; @@ -1312,7 +1314,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, /* * If btrfs_run_dealloc_range() already started I/O and unlocked - * the pages, we just need to account for them here. + * the folios, we just need to account for them here. */ if (ret == 1) { wbc->nr_to_write -= delalloc_to_write; @@ -1549,7 +1551,7 @@ static int __extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ct if (ret < 0) goto done; - ret = writepage_delalloc(BTRFS_I(inode), &folio->page, bio_ctrl->wbc); + ret = writepage_delalloc(BTRFS_I(inode), folio, bio_ctrl->wbc); if (ret == 1) return 0; if (ret) From patchwork Fri Jul 26 19:36:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743085 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.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 A2981149DF8 for ; Fri, 26 Jul 2024 19:36:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022618; cv=none; b=pnC70GFkf6JrI3soa59WcEIn0riqZfDlZcujHiis2R840Bi5oImrMQsA6L2Mkt/jTvbIploL6g4U2tOvY/e/YXtIcVccUhGMYTKFJ0wI8zcEv912ztAJOGuZDn5UPtBdPkDlnUqFEMaUx1uiqB/4vI/PlD9FHmf50JaM2D+X2+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022618; c=relaxed/simple; bh=EQLT9UHl2BuRaB4EnsHxnSlmspZ9yLCIcp8BqcZJkKY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BJvYbbNPCaCkStOc3NCJrpikzjdAqB7ULjLOs3E8Hujxi1vOZKbd/llbCRGg2dTRDg3BCHeke/LYpjcwYjH4HwB+w/VXTVSymejO9XDmFB2zJypvAvi/+fO/bkt810iN7xliLEt+29k+mTnd2rDgODY6yPMwTiwih/mnsBQe35Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=0OPHXX/V; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="0OPHXX/V" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-663dd13c0bbso430937b3.1 for ; Fri, 26 Jul 2024 12:36:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022615; x=1722627415; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DbayNxnh4cJQ1XDfQFZ8ECG4+Cqe8aWPiSA4REoJK/0=; b=0OPHXX/V/j/u+5CG3JlTVxox4mH6gMLuG5DK6KzQyDHEkGlOgubO9xSB3pg0x86aW9 7bkuvIKqBy1rrf9BXhmP58QFRbgfGm08lRv5VOJApOlAeAK5/5ggNpmQgk7lcFqs9Il9 jifIVCjJCwFAPZRPYdte4Ro8i2MKWCFMp0ROC3p8Tzh7bwKIE2cvf7dTnAaI5j1SZZMG gYgrpHxLNPilJHxapbeCw72mr9LLrbvjZUAz74KwBeUjLDfOI+1xpHboF7S58z9sVAQf P58dO3HlH5kh/vRuJdespduVqTF14WKUbvMbzJo0Z2M47w2EEoKGb6/CLNBiy8Bq0wqP iwGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022615; x=1722627415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DbayNxnh4cJQ1XDfQFZ8ECG4+Cqe8aWPiSA4REoJK/0=; b=dYIFSQdq/1zN1TNpCNgCRTJn3Kvq1lSWqeOlizuOHXFfkbS+onMoy1d2RdouhJnkOh 2/kEYDQ7Bhsq9dGw1rvfkmW9ZKENXygMxviPa+NsqGn/vk/q25obDxosaFE+q/2+FzKQ 5DstNfotDhmz5h61zqMonAj8FOZgRbT5ZYcBBGeD2tQL4uVXmMdFITmFi2SR23vjugjh b4ve46YFwjc5uqaA0F89vH/ah3xtmtyxg4daMdPuMBXmfGEH33BdZMrUV1rgdvCDVokQ Q+iO2LbcNlAOZbaVIYgCxDwyJ7lYk830zgUq927OZzJfvOwtawo2T3TWw53MfwAVqyCo /gNg== X-Gm-Message-State: AOJu0Yz2xRvCVuAirQfPaCZjRxwTZA7pVPTkb+nsDfxaR0E9YKtx9P/P XNM3zvgZ2RN/VvvAfNfThjxNTZ+UpfD1yAvOpZdSoSZYxDGX8kvszV4jPqMXHycVFsB/HLMt8qz C X-Google-Smtp-Source: AGHT+IEESv7bODAkIcxl0a31wYu7lpmAyG5AU95psCN2JUyvTMylpLN5itvBDkS7Np0cCrUxqycNCQ== X-Received: by 2002:a05:690c:3346:b0:632:7161:d16c with SMTP id 00721157ae682-67a090a5e7dmr9535427b3.28.1722022615412; Fri, 26 Jul 2024 12:36:55 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67566dd90dcsm10109327b3.1.2024.07.26.12.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:55 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 17/46] btrfs: convert find_lock_delalloc_range to use a folio Date: Fri, 26 Jul 2024 15:36:04 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of passing in a page for locked_page, pass in the folio instead. We only use the folio itself to validate some range assumptions, and then pass it into other functions. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 28 ++++++++++++++-------------- fs/btrfs/extent_io.h | 2 +- fs/btrfs/tests/extent-io-tests.c | 10 +++++----- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 382558fe1032..def12bb8b34d 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -304,8 +304,8 @@ static noinline int lock_delalloc_pages(struct inode *inode, */ EXPORT_FOR_TESTS noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, - struct page *locked_page, u64 *start, - u64 *end) + struct folio *locked_folio, + u64 *start, u64 *end) { struct btrfs_fs_info *fs_info = inode_to_fs_info(inode); struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; @@ -323,9 +323,9 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, /* Caller should pass a valid @end to indicate the search range end */ ASSERT(orig_end > orig_start); - /* The range should at least cover part of the page */ - ASSERT(!(orig_start >= page_offset(locked_page) + PAGE_SIZE || - orig_end <= page_offset(locked_page))); + /* The range should at least cover part of the folio */ + ASSERT(!(orig_start >= folio_pos(locked_folio) + folio_size(locked_folio) || + orig_end <= folio_pos(locked_folio))); again: /* step one, find a bunch of delalloc bytes starting at start */ delalloc_start = *start; @@ -342,25 +342,25 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, } /* - * start comes from the offset of locked_page. We have to lock - * pages in order, so we can't process delalloc bytes before - * locked_page + * start comes from the offset of locked_folio. We have to lock + * folios in order, so we can't process delalloc bytes before + * locked_folio */ if (delalloc_start < *start) delalloc_start = *start; /* - * make sure to limit the number of pages we try to lock down + * make sure to limit the number of folios we try to lock down */ if (delalloc_end + 1 - delalloc_start > max_bytes) delalloc_end = delalloc_start + max_bytes - 1; - /* step two, lock all the pages after the page that has start */ - ret = lock_delalloc_pages(inode, locked_page, + /* step two, lock all the folioss after the folios that has start */ + ret = lock_delalloc_pages(inode, &locked_folio->page, delalloc_start, delalloc_end); ASSERT(!ret || ret == -EAGAIN); if (ret == -EAGAIN) { - /* some of the pages are gone, lets avoid looping by + /* some of the folios are gone, lets avoid looping by * shortening the size of the delalloc range we're searching */ free_extent_state(cached_state); @@ -384,7 +384,7 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, unlock_extent(tree, delalloc_start, delalloc_end, &cached_state); if (!ret) { - __unlock_for_delalloc(inode, locked_page, + __unlock_for_delalloc(inode, &locked_folio->page, delalloc_start, delalloc_end); cond_resched(); goto again; @@ -1209,7 +1209,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, /* Lock all (subpage) delalloc ranges inside the folio first. */ while (delalloc_start < page_end) { delalloc_end = page_end; - if (!find_lock_delalloc_range(&inode->vfs_inode, &folio->page, + if (!find_lock_delalloc_range(&inode->vfs_inode, folio, &delalloc_start, &delalloc_end)) { delalloc_start = delalloc_end + 1; continue; diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index dceebd76c7d1..1dd295e1b5a5 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -368,7 +368,7 @@ int btrfs_alloc_folio_array(unsigned int nr_folios, struct folio **folio_array); #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS bool find_lock_delalloc_range(struct inode *inode, - struct page *locked_page, u64 *start, + struct folio *locked_folio, u64 *start, u64 *end); #endif struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c index 865d4af4b303..0a2dbfaaf49e 100644 --- a/fs/btrfs/tests/extent-io-tests.c +++ b/fs/btrfs/tests/extent-io-tests.c @@ -180,7 +180,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize) set_extent_bit(tmp, 0, sectorsize - 1, EXTENT_DELALLOC, NULL); start = 0; end = start + PAGE_SIZE - 1; - found = find_lock_delalloc_range(inode, locked_page, &start, + found = find_lock_delalloc_range(inode, page_folio(locked_page), &start, &end); if (!found) { test_err("should have found at least one delalloc"); @@ -211,7 +211,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize) set_extent_bit(tmp, sectorsize, max_bytes - 1, EXTENT_DELALLOC, NULL); start = test_start; end = start + PAGE_SIZE - 1; - found = find_lock_delalloc_range(inode, locked_page, &start, + found = find_lock_delalloc_range(inode, page_folio(locked_page), &start, &end); if (!found) { test_err("couldn't find delalloc in our range"); @@ -245,7 +245,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize) } start = test_start; end = start + PAGE_SIZE - 1; - found = find_lock_delalloc_range(inode, locked_page, &start, + found = find_lock_delalloc_range(inode, page_folio(locked_page), &start, &end); if (found) { test_err("found range when we shouldn't have"); @@ -266,7 +266,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize) set_extent_bit(tmp, max_bytes, total_dirty - 1, EXTENT_DELALLOC, NULL); start = test_start; end = start + PAGE_SIZE - 1; - found = find_lock_delalloc_range(inode, locked_page, &start, + found = find_lock_delalloc_range(inode, page_folio(locked_page), &start, &end); if (!found) { test_err("didn't find our range"); @@ -307,7 +307,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize) * this changes at any point in the future we will need to fix this * tests expected behavior. */ - found = find_lock_delalloc_range(inode, locked_page, &start, + found = find_lock_delalloc_range(inode, page_folio(locked_page), &start, &end); if (!found) { test_err("didn't find our range"); From patchwork Fri Jul 26 19:36:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743086 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 78F80149DFC for ; Fri, 26 Jul 2024 19:36:57 +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=1722022618; cv=none; b=AoB29YdaQd8l+NTX/+CaExhnzHjPC9afMxCDEENyT9JFmp11ynqC6fhBEo7aoaOVGdS1av5Ud4LZniPLQ8Ogu3S0PIMh3yQIqS/jXFK0LnpS9gfhjqaD8Z1QPocOiI6mSRXoqyVg6wH6cRWyyPmlnqwi6TwEY9RKB0sZ9SvdYxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022618; c=relaxed/simple; bh=jTlEh59LEmakLdi5ZAwgkrRCYD9VBYtOVU5S3mmV/0k=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mj/c5wmITwY+dIB9U297xfLqadEO6QPy+xJ0fXrDDwVuh38RH2bn9yMO6E+IOyuWk05bzABNfweGnbeOEU0YHx/OMhR+vJEYFzQcmVwp8DGImNuTtL9mdItU+tZPGrXc6HdO13VPDDFski2jW9X1oPtXwnlVYcDTyuq2S9t4Oqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=aSntczgv; arc=none smtp.client-ip=209.85.128.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="aSntczgv" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-664ccd158b0so358767b3.1 for ; Fri, 26 Jul 2024 12:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022616; x=1722627416; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=35e2ClCxEe/wCEeaddbhCpQMYPr9dVCHVaST0yK0vPs=; b=aSntczgvIkE7rFbu7EtrAtGgWI9hYfBZ1ot2pkAw986Alg3DnBI0WcO0bt2j7y8kJ5 KZDvnFR7iDqTSSAsuRsOc5PcB+zYbqJD8Ou67WpbqS0W4+YWxeqAXXPdsrGk433txDTs toWEUcZfrugC6QXfro88pW4+Nh8p46o6ZfiLSJLheZIOVQYe40WelIadBTCoKD3lnenm KX3bVDaMGB3RqEsmxO/Wh2ccqxG+eW4Fsz0z1tFABccSJhXPYO0Pl02Uzd3yWQaqajr4 oeSSYpUxFNBv28OskWSi3wzOEh/VK5H3yLPHpsPZ2IGGG+syRHVHax+f0xxUSBoEcK+w d/IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022616; x=1722627416; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=35e2ClCxEe/wCEeaddbhCpQMYPr9dVCHVaST0yK0vPs=; b=Cj2Ft3tgVUZhFRNxwg9Jkg0qsyi8O5WJ8dLSTv97KA1s+7YR+rbqL4An0RWdCY7z8r yiPDv8wIuQwtCWCo/urQKb2f0/bOsW4fX3xJeuuPG4VinaCTJaPvc8rBkudPtZ5r2pmY tnnXpAO2819TAYoGxocEO8HqVZDPep+/JREtFMZFB1pOZDzlBS+PGt/XJ8hxD2DYRBws 97jeyysMRGVBqp0Fiyj07qxYYJ218CDurUXOA5/jwums+2FSY8GYIoXc4KevSEg1f5RT nD2car3JFYkEGDD6gQ3HnhIhx2jCMy3Q7+Wt4UDpjp0HUD0JZFkqxJzZ36FeGgpjGiBg S5iA== X-Gm-Message-State: AOJu0Yz1PmCIq/Mi78MUmB9aVSop0Suvlvcv5AX92Fdk7YCJxoVb56tY 0tOaXOQeOLTut1N5rfKKt/+keTy5TYIq1U7zfOSzZm2Tdai1b2hjVx4SKTRbeDf3G9EBnN+O2Uf j X-Google-Smtp-Source: AGHT+IGQAtVNHduZS3iV+tTGUwdRXw1ZeW1n+rozJgOTy5Ss4tDczRpldf+iblV34RkxNgoEOkPsWA== X-Received: by 2002:a81:5c83:0:b0:644:2639:8645 with SMTP id 00721157ae682-67a07989c5bmr9400747b3.26.1722022616445; Fri, 26 Jul 2024 12:36:56 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756795e824sm9961457b3.37.2024.07.26.12.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:56 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 18/46] btrfs: convert lock_delalloc_pages to take a folio Date: Fri, 26 Jul 2024 15:36:05 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Also rename lock_delalloc_pages => lock_delalloc_folios in the process, now that it exclusively works on folios. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index def12bb8b34d..33c45b6e8969 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -230,10 +230,9 @@ static noinline void __unlock_for_delalloc(const struct inode *inode, PAGE_UNLOCK); } -static noinline int lock_delalloc_pages(struct inode *inode, - const struct page *locked_page, - u64 start, - u64 end) +static noinline int lock_delalloc_folios(struct inode *inode, + const struct folio *locked_folio, + u64 start, u64 end) { struct btrfs_fs_info *fs_info = inode_to_fs_info(inode); struct address_space *mapping = inode->i_mapping; @@ -243,7 +242,7 @@ static noinline int lock_delalloc_pages(struct inode *inode, u64 processed_end = start; struct folio_batch fbatch; - if (index == locked_page->index && index == end_index) + if (index == locked_folio->index && index == end_index) return 0; folio_batch_init(&fbatch); @@ -257,23 +256,22 @@ static noinline int lock_delalloc_pages(struct inode *inode, for (i = 0; i < found_folios; i++) { struct folio *folio = fbatch.folios[i]; - struct page *page = folio_page(folio, 0); u32 len = end + 1 - start; - if (page == locked_page) + if (folio == locked_folio) continue; if (btrfs_folio_start_writer_lock(fs_info, folio, start, len)) goto out; - if (!PageDirty(page) || page->mapping != mapping) { + if (!folio_test_dirty(folio) || folio->mapping != mapping) { btrfs_folio_end_writer_lock(fs_info, folio, start, len); goto out; } - processed_end = page_offset(page) + PAGE_SIZE - 1; + processed_end = folio_pos(folio) + folio_size(folio) - 1; } folio_batch_release(&fbatch); cond_resched(); @@ -283,7 +281,8 @@ static noinline int lock_delalloc_pages(struct inode *inode, out: folio_batch_release(&fbatch); if (processed_end > start) - __unlock_for_delalloc(inode, locked_page, start, processed_end); + __unlock_for_delalloc(inode, &locked_folio->page, start, + processed_end); return -EAGAIN; } @@ -356,8 +355,8 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, delalloc_end = delalloc_start + max_bytes - 1; /* step two, lock all the folioss after the folios that has start */ - ret = lock_delalloc_pages(inode, &locked_folio->page, - delalloc_start, delalloc_end); + ret = lock_delalloc_folios(inode, locked_folio, delalloc_start, + delalloc_end); ASSERT(!ret || ret == -EAGAIN); if (ret == -EAGAIN) { /* some of the folios are gone, lets avoid looping by From patchwork Fri Jul 26 19:36:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743087 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.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 80104149E03 for ; Fri, 26 Jul 2024 19:36:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022619; cv=none; b=J8hPUReQN5yFmIASqjBRqpcLtyNb4WPGD9A0H8C3CuoEZ6F9fx/+NSuppjvcZV7l13HadvhDTf2eULV4+QAeT7V7Wq7pjtxYgJ1TP3ahcuxhnm/7P+8BjGz3R+IKW9LW71Zd6DA9BK4ZcU4m/2nU+U8bHWOrf356OQNhiIYaBHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022619; c=relaxed/simple; bh=RrKlZF4ASZs2BJuUReQ+tnscDatJQ7ZcZLq8kLvFKMY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U5m10qnWVuRqureuV0VoXt82bbbkI33+a6reYEmbsKH2ecV7E8/g85lbageiH61FjecoSZCww3PLOCaxSUhro74FTJB+eYpK5VfywBGjAuHkcjFIxAOr7dRyiBZEQwTn3QfGh0ywKANsCn2KSRv5n33GbSEmt+7b4/Zq/mkf9mU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=r6xTzSPx; arc=none smtp.client-ip=209.85.128.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="r6xTzSPx" Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-66599ca3470so397707b3.2 for ; Fri, 26 Jul 2024 12:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022617; x=1722627417; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6a/M6OQLHFDbam00R0s6KpY830Mlb80NojtuH2K2MnU=; b=r6xTzSPxGZuZHUvYLTmYYudl+cMh3iy6U39XWh8gBWgAow0RBBGjxzparSJ84ed7At dR44PKFJt3VvVxwsMERRDt6nsz1vUwG6TW4U8xNjkJEH6zkBI11Q6LnsILmhlh4IXxP1 1pAPK2XO/iMtlUu3NxOFQT5aLCMX8esreUkzXQaJcEotOxa634X694rp+4G9HN4N0VLe E3j2uI1AnHTIDnTznp5ycq11RY580YpVjR9tNE/Pa3PHuSa5ZKQHpwqMH/6YZr+2V3VE qoOCJJl6WjlzIDWhBV2M6pwIaOVS87DWrpV05Fy7ai6BrNOKSJJTBi5lEdpMOyx/DExN uh/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022617; x=1722627417; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6a/M6OQLHFDbam00R0s6KpY830Mlb80NojtuH2K2MnU=; b=rQ6K0+MLNAHdNgILUMJK4Wl6Alu7c6BoCSvWrImLZtegvhdN0ySQEXrIfb+8UQ//yy eRBwDAajW+5E0T2OSR5RFyh3rB1kdKi6PIukiAxSH5h6Q4WoVj2jvum42dp3zUw88apE Sq18/YObj3auHABPkd7sUOHawcX7f7bY5DW2FNjEk6oSfUnybizu3TmoUFt9b+w+kHmc 2Ovj7B9BtftHSYHd+aCew6sFvL6bTuTBFnFEm3eeOUqgdqsuPvLN/K+ZhlI8/E1mI/LT QTigMnFmK62uFnhTgUr6H/7SoKlXzGLnq1XjjdEOBTFKXkLWzChXXEkB+gqqu8wKGe7f o8iA== X-Gm-Message-State: AOJu0YyuCGkRSLmYSGClv3xqB+IclzK5KX4C8ps6u8WIY7oeqkggu1M7 D0ygA162JbF36aAxo20lUqwCjSL7coVGW45/vifPCgS+21KSxSoJTFY/4Lw6ZmjcWkN0QlX5Doh e X-Google-Smtp-Source: AGHT+IG7+QnB8p/VxZHVi+aJew5jvEzl5cPj9TwpMgI/beCyEkRtr68NRTaf0S3xkIZK7wm5k0CANQ== X-Received: by 2002:a05:690c:4803:b0:664:a85d:47c6 with SMTP id 00721157ae682-67a09f4acf5mr8769167b3.33.1722022617416; Fri, 26 Jul 2024 12:36:57 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756b9be42fsm9744337b3.105.2024.07.26.12.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:57 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 19/46] btrfs: convert __unlock_for_delalloc to take a folio Date: Fri, 26 Jul 2024 15:36:06 -0400 Message-ID: <3129bd4787f666c793621f9c80e3f15536282381.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All of the callers have a folio at this point, update __unlock_for_delalloc to take a folio so that it's consistent with its callers. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 33c45b6e8969..46d26f54e9d4 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -216,18 +216,18 @@ static void __process_pages_contig(struct address_space *mapping, } static noinline void __unlock_for_delalloc(const struct inode *inode, - const struct page *locked_page, + const struct folio *locked_folio, u64 start, u64 end) { unsigned long index = start >> PAGE_SHIFT; unsigned long end_index = end >> PAGE_SHIFT; - ASSERT(locked_page); - if (index == locked_page->index && end_index == index) + ASSERT(locked_folio); + if (index == locked_folio->index && end_index == index) return; - __process_pages_contig(inode->i_mapping, locked_page, start, end, - PAGE_UNLOCK); + __process_pages_contig(inode->i_mapping, &locked_folio->page, start, + end, PAGE_UNLOCK); } static noinline int lock_delalloc_folios(struct inode *inode, @@ -281,7 +281,7 @@ static noinline int lock_delalloc_folios(struct inode *inode, out: folio_batch_release(&fbatch); if (processed_end > start) - __unlock_for_delalloc(inode, &locked_folio->page, start, + __unlock_for_delalloc(inode, locked_folio, start, processed_end); return -EAGAIN; } @@ -383,8 +383,8 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, unlock_extent(tree, delalloc_start, delalloc_end, &cached_state); if (!ret) { - __unlock_for_delalloc(inode, &locked_folio->page, - delalloc_start, delalloc_end); + __unlock_for_delalloc(inode, locked_folio, delalloc_start, + delalloc_end); cond_resched(); goto again; } @@ -1266,7 +1266,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, */ unlock_extent(&inode->io_tree, found_start, found_start + found_len - 1, NULL); - __unlock_for_delalloc(&inode->vfs_inode, &folio->page, + __unlock_for_delalloc(&inode->vfs_inode, folio, found_start, found_start + found_len - 1); } From patchwork Fri Jul 26 19:36:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743088 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.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 D7983149E1D for ; Fri, 26 Jul 2024 19:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022621; cv=none; b=dVp3GH2iZcyHSWBVSVN5rx062bFVP3HLiaK/ogj1W/8+b094gMEGxErOuFPe47wZs04Ae/0XW1GzazuDFDKYIv9EJf/nmnqF9A9klj+h8xXdtpIncu1+d9J03+rA3JipYIe+gkQHA8H1CETTSMraK+kQKV5DcGN+LYx5/wcLk+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022621; c=relaxed/simple; bh=AJB5p7TdKPMaVdU2ixa45kQchnsiFFTQWnJ0dYHmx10=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z3GICcJkCtw0w1q3LhBGkMk2NYU7sYkXIZ0xQ3MMxNd+Oh+w2+meUqnazyPD7Romz8IQs9RCyBGKooZA2vR9YbxAx7OWA/THtuY7N3hZtQRQA2vS9vUWJ/NDgdMudLEMO9mdRQ/YuMlnrbau1z/kRdZJ/6yBFI4nPGvSg4PTzxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=xSyQVFC0; arc=none smtp.client-ip=209.85.219.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="xSyQVFC0" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e0878971aa9so41128276.0 for ; Fri, 26 Jul 2024 12:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022618; x=1722627418; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xoRWBdvdZDUCSVjXxsglCj49tecBfXtcCNEA/2zgHrQ=; b=xSyQVFC0TJYLwAlW9KjlKkrK+LmtiGWJ+wZPqfCnzuZ54rxHBASMf2id+9DcFRg85l 2YF83OQvSuGDDfrpCo8PU8C9FkEhhaCuq8KDIH+kDvfF743uY5RBZKz2dMY7VYCqtvap HV5ARh2iB6Y8lr+b7GOERKHDe0n4ueeCSpslNSZhDBmqiC4oJ/Z4J/G2LZwQhMGUcwPm Zw0r72p1K3HgFjPYMV5U+RwrJ52sFlIy17dRri/9pq7uIUacLGU6L6bJ2po8SiHp3uhH wHOfPld0c1JVnr1KgbTkYnBADu00om3R/T5gDqeWhXksLgtSGeNgd8e7B/yEfRJfHgS4 236A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022618; x=1722627418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xoRWBdvdZDUCSVjXxsglCj49tecBfXtcCNEA/2zgHrQ=; b=G5jpFRdzwvIAxDrYEcn1te5KKAG1l/mi3JJfay/EQCy85ICxa5dJM2QQ+sFAfkRq7+ tiQoLhMn5wCk83JMwNIl2gwQ8DMmuovTbXCJvkOtehdGhi5JhvL0FkGqUkbCbqjHteRp Bsd9ZT4Tn5/6rbonZHAjErzZto+4JM7/SjX/KufWYYtuL5C5HUJdrrOSCrFsEoNK3ARr RuzOkhqczcQC22qtFgYY5y4JKAaRa/IbSJaUqfknZx7Lk2FqV4bSP+mO4Kkn4aKG0sMf 3QX6mriM5vdjNVG/oWtv0uzd9wlfw4Ay7Ockl2tW52RKM+RZHqq3hOXBPbSlaThTe6uX eJaw== X-Gm-Message-State: AOJu0YxCgRzp7qQJdbwzVU9wpXp6/Ge9TG5V8Zb7Qooq19UgWrvIppPg 1zKlFGge8EoVnnWZkiXPRKVrqFKkDx2cHPJMsgGpeDR8Y8Z1dQ/xs9n73Tklu4VMTLUj0BK1G2h F X-Google-Smtp-Source: AGHT+IGRKFwPT7phblKB5c2eyoJTVNV1y2uMtBVDTfJOsBbeckc7uOgZcrpYC7TgnybjNRj4ANJcZQ== X-Received: by 2002:a25:5f0b:0:b0:e03:a923:8720 with SMTP id 3f1490d57ef6-e0b5520ba8amr667441276.0.1722022618456; Fri, 26 Jul 2024 12:36:58 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0b2a28d442sm841094276.38.2024.07.26.12.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:58 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 20/46] btrfs: convert __process_pages_contig to take a folio Date: Fri, 26 Jul 2024 15:36:07 -0400 Message-ID: <2c0a83b7d29e5ee81fb2861b29fc0016907b2c88.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This operates mostly on folios, update it to take a folio for the locked folio instead of the page, rename from __process_pages_contig => __process_folios_contig. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 46d26f54e9d4..d49f3adf7d86 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -187,9 +187,9 @@ static void process_one_page(struct btrfs_fs_info *fs_info, btrfs_folio_end_writer_lock(fs_info, folio, start, len); } -static void __process_pages_contig(struct address_space *mapping, - const struct page *locked_page, u64 start, u64 end, - unsigned long page_ops) +static void __process_folios_contig(struct address_space *mapping, + const struct folio *locked_folio, u64 start, + u64 end, unsigned long page_ops) { struct btrfs_fs_info *fs_info = inode_to_fs_info(mapping->host); pgoff_t start_index = start >> PAGE_SHIFT; @@ -207,8 +207,9 @@ static void __process_pages_contig(struct address_space *mapping, for (i = 0; i < found_folios; i++) { struct folio *folio = fbatch.folios[i]; - process_one_page(fs_info, &folio->page, locked_page, - page_ops, start, end); + process_one_page(fs_info, &folio->page, + &locked_folio->page, page_ops, start, + end); } folio_batch_release(&fbatch); cond_resched(); @@ -226,8 +227,8 @@ static noinline void __unlock_for_delalloc(const struct inode *inode, if (index == locked_folio->index && end_index == index) return; - __process_pages_contig(inode->i_mapping, &locked_folio->page, start, - end, PAGE_UNLOCK); + __process_folios_contig(inode->i_mapping, locked_folio, start, end, + PAGE_UNLOCK); } static noinline int lock_delalloc_folios(struct inode *inode, @@ -401,8 +402,8 @@ void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end, { clear_extent_bit(&inode->io_tree, start, end, clear_bits, cached); - __process_pages_contig(inode->vfs_inode.i_mapping, locked_page, - start, end, page_ops); + __process_folios_contig(inode->vfs_inode.i_mapping, + page_folio(locked_page), start, end, page_ops); } static bool btrfs_verify_folio(struct folio *folio, u64 start, u32 len) From patchwork Fri Jul 26 19:36:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743089 Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.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 933024F218 for ; Fri, 26 Jul 2024 19:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022621; cv=none; b=ZdszY9x8A9qHyfycmKhVoOW0oUc5BIqeDJ+1YTcNmE029idLphIcUcRi16xKLdDjYozkrJRcCPruElWrXj3YLm65V8o4cvjL8QHm0FAPCru7PtKmWBYeI+hrfYVO5Ukm7frpvE7t7T/5+Ob0JamsmivbLerzSaA4q1VCMvnXz5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022621; c=relaxed/simple; bh=zhmQJbZdHkNBZ6G5bU+E2kNgl1KSNHA261epgdN0HBk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lQxgjfHCmW9GdhCl8SXqLhv0cxe1kW6vWNWYWU9JfSU8HyJ/mMLeYanSUusHy7B0dyyws4+FkW0LSSFwGGc1iTBzcvAsOq3iMH5rWTScq+PJYKRa2Bm8m1KclbONy01R1x2DQI1/7Tc85QVT7V5ETIZoIJnFECM0qfKMKIvbLPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=xWhTrxFH; arc=none smtp.client-ip=209.85.219.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="xWhTrxFH" Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-e0b167da277so21530276.3 for ; Fri, 26 Jul 2024 12:37:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022619; x=1722627419; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=TPn+S0axWk5wx0jNFvxs9ojQnS1R3d3jhq9+IGiBmLA=; b=xWhTrxFHhqnnIfAyj+dHeP9pLpX1FMpTXfbZ7ha5SJYJMp9FFimvaw0YGZQUq2aOly cQyf8f4ch8Qo76PY8WyBqXaRdZCF8Ynj/vV4E5EcbS+5hMkynorw2usLqYG3Zny/cO/f w+hK5BG2+y+T+Ax/qrkfEqNDj9WP40uzcCkcCPJ2QGXauftZxYljar5h/t5BTUrU1e5+ tR27EAPukC29RVMRsFpIYWYsJx5x/CbX2qalsxClIMSsYUg5RRgivu6LRMK78q8t9K3K rBl3owpay3tdRfrlKuZ1ka/T5CHgBpRd/e5m5BtYW9RAfyZdSjAzvFxOVMZcbqKOzGaa ReBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022619; x=1722627419; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TPn+S0axWk5wx0jNFvxs9ojQnS1R3d3jhq9+IGiBmLA=; b=xAANgFrcO/wW4/vuJTHNHv13AhGbAftL125hIUhqlqLH6b9Quz1gy3wVqaOF/DVCEh gEm2C/TGxb+2BmRHSHY97q+AKsTfnMA4wqYyoBxhIkzrTZJfYHOeUviztYFoAYJ6/6gd b5689lUw4PQ5mWsGu/0Ima8fn10qCoz0ONZVYzVJQQxTC6XkzSdXq9/r4sR1KtKUCs6F TbDuAbzhzmlIw8Y5U8F4FeqVXbdKnmjJlyk8t5ZlLrTzvtUL2yasMWIJxotiBH4p0uYZ qiUKIBzaNBUk+Z47JpC+0Bwa8EN64i7FpAdk/j77Ax4QXBty3LmkODS1GSouYcqonG/K at1Q== X-Gm-Message-State: AOJu0YyA4pIPkixZv01gMlVWf5sYxTqchrZ7SX7fncRtEw3I0KWoGmgM GzH1gRaTZ+RpRpjHZ2SyiLhphZ4sI86Ebhtj2igmV2TpLGWfRPhTwZTCO96l8b8/Vlc7CmoK/LC w X-Google-Smtp-Source: AGHT+IG+h214BhWwbPul+jCELALj1eTezGrg7VI/oMpRKIHO2crP9z2YtG+bNQmncFulvb3O69TpMw== X-Received: by 2002:a81:6905:0:b0:65f:93c1:fee9 with SMTP id 00721157ae682-67a05c8b8f9mr9835637b3.9.1722022619532; Fri, 26 Jul 2024 12:36:59 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756795e7d3sm10030507b3.32.2024.07.26.12.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:36:59 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 21/46] btrfs: convert process_one_page to operate only on folios Date: Fri, 26 Jul 2024 15:36:08 -0400 Message-ID: <8516487d309169dc2c7efadde01b3d29e6aa6038.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that this mostly uses folios, update it to take folios, use the folios that are passed in, and rename from process_one_page => process_one_folio. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index d49f3adf7d86..b944dcd9e941 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -164,11 +164,10 @@ void __cold extent_buffer_free_cachep(void) kmem_cache_destroy(extent_buffer_cache); } -static void process_one_page(struct btrfs_fs_info *fs_info, - struct page *page, const struct page *locked_page, - unsigned long page_ops, u64 start, u64 end) +static void process_one_folio(struct btrfs_fs_info *fs_info, + struct folio *folio, const struct folio *locked_folio, + unsigned long page_ops, u64 start, u64 end) { - struct folio *folio = page_folio(page); u32 len; ASSERT(end + 1 - start != 0 && end + 1 - start < U32_MAX); @@ -183,7 +182,7 @@ static void process_one_page(struct btrfs_fs_info *fs_info, if (page_ops & PAGE_END_WRITEBACK) btrfs_folio_clamp_clear_writeback(fs_info, folio, start, len); - if (page != locked_page && (page_ops & PAGE_UNLOCK)) + if (folio != locked_folio && (page_ops & PAGE_UNLOCK)) btrfs_folio_end_writer_lock(fs_info, folio, start, len); } @@ -207,9 +206,8 @@ static void __process_folios_contig(struct address_space *mapping, for (i = 0; i < found_folios; i++) { struct folio *folio = fbatch.folios[i]; - process_one_page(fs_info, &folio->page, - &locked_folio->page, page_ops, start, - end); + process_one_folio(fs_info, folio, locked_folio, + page_ops, start, end); } folio_batch_release(&fbatch); cond_resched(); From patchwork Fri Jul 26 19:36:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743090 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2F4B14A090 for ; Fri, 26 Jul 2024 19:37:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022623; cv=none; b=MDCnOC0jrncY6DH9w87dc63KtD1dk9czecyEDhffrT9lH6Lqt/zKcoDwZQPAHVq3snAbttfTTXmLBF8/vIbGWj4eF397nXbOt86d9cwyM2T5JRHdcjMYcJpWzTlFlxAXAOLZUVsNpuqMEHLIDwDrN9+nWtNpPaptcO/7i5PjKvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022623; c=relaxed/simple; bh=c/ufI9B2NqkYuGfheJ3QX0CMLoX2hZOxlxuTMxg1grc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OFB0Vps+DuM4Rlab2kDjqExcaLQ/aCXMEefQd/0SzyoITACWurL4QozjqwWvW6YO1junocht3yglQ5jBGsgnrb1cx0FvsqJhh3wOsrJ74F+eA9pj9j3gQIqJbu7fJVdVwLUuF0BTG6iYfmOOnQIzLeKF+b3MwO05TdZ43eVOM2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=Cf1CbdEA; arc=none smtp.client-ip=209.85.219.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="Cf1CbdEA" Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-e0871f82ff8so29635276.3 for ; Fri, 26 Jul 2024 12:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022621; x=1722627421; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cZSLg3LGOqD0LLTl1IMwMID+6rjptKfBMm6YofAfBuc=; b=Cf1CbdEAvtT2l/yhri1kxUqnO4nvLv6oLSlgCPfcuW//v9Y/oIG9mjz9qh4YLNZS9y qtKjM5Xnvjl3Fim4k27s/x9u4O4Vz1VJxQMuAyhQDLadrnknx23eMOkNs2LCqugXlLm5 DcGlLjjcu9Pve8avZCaHSy3UM3QACZUXkXsC49QG0rQCZ8itHzy6953fcGitTwrebJYv mVH02ZSPDv6/ic2bGYIQpiZKSbeNPF/nyTpXtSNJWCmCduKXxQwtr0idXWcMLOE2dtOT Kfa/GN2yQJAxlnar0p3DcP3c/YOu8zdWWMzGb1uBXUn9z2AGs2ZrVWtLVlHZsfcTk9nc Fh2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022621; x=1722627421; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cZSLg3LGOqD0LLTl1IMwMID+6rjptKfBMm6YofAfBuc=; b=MGTVv5a7YEyfkWzk9rPZWTABlRcb8a/oS/lFBfoKiGDAKjtNy8XIAVWxWwAvq5aJPy VPnOX6N6MsNvzPMlBK2xY7QpYbiXeGQyvy6vbGBdllgt0im7WMEWf9eNGEYvUhaUREyM eIPJIWdUOIVof0kp0Y2mtemgJ/UDmkLNFfbW67l6X9EzBGtRzf0lIvSLwSV8QzJ2VtRH tR2ML31OQNVg3nrgYKs7/YW/VqWtRQ1YhysMvR1o1WCMjzMjr2Tw0yT2XJKVfro3RrAz 6YbmE7M0Q42JQOogPvDWYkem2lxBtFWW9r5kfUxrPdNWCZctLbyOtt2xvMJsErtQwyw5 q6dA== X-Gm-Message-State: AOJu0YxaDDmTbYtssvsU8HUEywxTXFBGL+4IRk7L6/xLnHc5gMavOl3I XtvsHUcqJFK+AroVYwDUeUzWk0n+vX8X9bb8KjeDbQvVuXDEW+CWQkBKFg0GMtD5NKt+mb83AY3 p X-Google-Smtp-Source: AGHT+IEoEUaXmvbzUkaHDMFErdB7+ZYDb+LfhbzAtEM3CQTfzzNDaKSv4aSekFAeypMs0FifqzZyVA== X-Received: by 2002:a25:7413:0:b0:e05:ed3c:47cd with SMTP id 3f1490d57ef6-e0b544feef4mr834833276.20.1722022620890; Fri, 26 Jul 2024 12:37:00 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0b2a70d291sm844512276.52.2024.07.26.12.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:00 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 22/46] btrfs: convert extent_clear_unlock_delalloc to take a folio Date: Fri, 26 Jul 2024 15:36:09 -0400 Message-ID: <79fd01116f9f1648fb37aebf5e3a74065bb80014.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of taking the locked page, take the locked folio so we can pass that into __process_folios_contig. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 6 +++--- fs/btrfs/extent_io.h | 2 +- fs/btrfs/inode.c | 25 ++++++++++++++----------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index b944dcd9e941..6036fd6b9b79 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -394,14 +394,14 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, } void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end, - const struct page *locked_page, + const struct folio *locked_folio, struct extent_state **cached, u32 clear_bits, unsigned long page_ops) { clear_extent_bit(&inode->io_tree, start, end, clear_bits, cached); - __process_folios_contig(inode->vfs_inode.i_mapping, - page_folio(locked_page), start, end, page_ops); + __process_folios_contig(inode->vfs_inode.i_mapping, locked_folio, start, + end, page_ops); } static bool btrfs_verify_folio(struct folio *folio, u64 start, u32 len) diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 1dd295e1b5a5..5d36031578ff 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -354,7 +354,7 @@ void set_extent_buffer_dirty(struct extent_buffer *eb); void set_extent_buffer_uptodate(struct extent_buffer *eb); void clear_extent_buffer_uptodate(struct extent_buffer *eb); void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end, - const struct page *locked_page, + const struct folio *locked_folio, struct extent_state **cached, u32 bits_to_clear, unsigned long page_ops); int extent_invalidate_folio(struct extent_io_tree *tree, diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a8744d2c6a97..199f783680e2 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -743,10 +743,10 @@ static noinline int cow_file_range_inline(struct btrfs_inode *inode, if (ret == 0) locked_page = NULL; - extent_clear_unlock_delalloc(inode, offset, end, locked_page, &cached, - clear_flags, - PAGE_UNLOCK | PAGE_START_WRITEBACK | - PAGE_END_WRITEBACK); + extent_clear_unlock_delalloc(inode, offset, end, + page_folio(locked_page), &cached, + clear_flags, PAGE_UNLOCK | + PAGE_START_WRITEBACK | PAGE_END_WRITEBACK); return ret; } @@ -1501,7 +1501,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode, page_ops |= PAGE_SET_ORDERED; extent_clear_unlock_delalloc(inode, start, start + ram_size - 1, - locked_page, &cached, + page_folio(locked_page), &cached, EXTENT_LOCKED | EXTENT_DELALLOC, page_ops); if (num_bytes < cur_alloc_size) @@ -1560,7 +1560,8 @@ static noinline int cow_file_range(struct btrfs_inode *inode, if (!locked_page) mapping_set_error(inode->vfs_inode.i_mapping, ret); extent_clear_unlock_delalloc(inode, orig_start, start - 1, - locked_page, NULL, 0, page_ops); + page_folio(locked_page), NULL, 0, + page_ops); } /* @@ -1583,7 +1584,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode, if (extent_reserved) { extent_clear_unlock_delalloc(inode, start, start + cur_alloc_size - 1, - locked_page, &cached, + page_folio(locked_page), &cached, clear_bits, page_ops); btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL); @@ -1598,8 +1599,9 @@ static noinline int cow_file_range(struct btrfs_inode *inode, */ if (start < end) { clear_bits |= EXTENT_CLEAR_DATA_RESV; - extent_clear_unlock_delalloc(inode, start, end, locked_page, - &cached, clear_bits, page_ops); + extent_clear_unlock_delalloc(inode, start, end, + page_folio(locked_page), &cached, + clear_bits, page_ops); btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL); } return ret; @@ -2207,7 +2209,8 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, btrfs_put_ordered_extent(ordered); extent_clear_unlock_delalloc(inode, cur_offset, nocow_end, - locked_page, &cached_state, + page_folio(locked_page), + &cached_state, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_CLEAR_DATA_RESV, PAGE_UNLOCK | PAGE_SET_ORDERED); @@ -2256,7 +2259,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, lock_extent(&inode->io_tree, cur_offset, end, &cached); extent_clear_unlock_delalloc(inode, cur_offset, end, - locked_page, &cached, + page_folio(locked_page), &cached, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING, PAGE_UNLOCK | From patchwork Fri Jul 26 19:36:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743091 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 1A13D4F218 for ; Fri, 26 Jul 2024 19:37:02 +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=1722022624; cv=none; b=UerVzgfvg42Ed/3gKB0GB2diS3Ogn8dOfmXdxf0wiRnRz22BGBMFgvjKOh38yy76RIBOc83xhvobbDGdMr1S6xT9duPtPVO3mDaizV3k1fIzpotVRCf0dtP182bhdMeeJPnBiQQ8ejq5/iybkfbchBnQ10q4UbADB8gMAm2xk5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022624; c=relaxed/simple; bh=fVkn7ZZNwEWhV8zvazU6X97QDpdJBEJJs3GhCg/1Q3E=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mMDOdNCRunvVDT5Hw9n5cuKBWUfev0sfW7I7yElZNCJZcvReS9X58Hk3wA7BrlPJbbtrx4S06GHrCltgfx2gYB9G1JN+c+4VtZARefWzqa4rK9YhiPA1UmJyCk6ANXvhwyxf61ecnR+Au2I2wba5E5TTswlU79IREpJKtOqf6og= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=2eEaY6pz; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="2eEaY6pz" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-65f8626780aso315897b3.3 for ; Fri, 26 Jul 2024 12:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022622; x=1722627422; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HsXB8DX4/GdX+DMyVL3t9hKrZVLik5IHtqIcuefl6X4=; b=2eEaY6pz93GHAP5ehADiGcCRuH8zAuwowC5N8mNzWgQ2ZZgOE0R7DJb5qfMlnSr8Rv 8g6CB5tLu2eHaHnY9gNNrGPkkyMM6QGBW8sJ+AkV7iX8scJi13WEDPwc6JsGCElXM/c7 AJ6ngSSREka8iToTigVgkgayueZnhXT4HeVdIORo1oQLrtt+KwyfP+ce7k9ttLeBHlT6 uT8/onxIC15bJjWGvo83e+ILBro54+p1k/kkdziF+0Wm4pFpWqTL/MQomoOz8Fn5QSrG lKSYWzh6var84wzdYKWr+ctWRNmxtclgBI9T2JFFOTZvWoxTd2Rtjdv1CCcazB7QDPNj JXwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022622; x=1722627422; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HsXB8DX4/GdX+DMyVL3t9hKrZVLik5IHtqIcuefl6X4=; b=tEVzs8fxKxqycmLGDxSmcA6eFJr7wvlIpiuze+FTRS4V9ABFopGD5FzcwsgfeZzgLO 1JqVc/o4w/8mc7fdQleZZRmqm8iXhFHX/onzoL44nWMP6U8IAmhmYeDXOFT3yseo6sa2 8YmgIPD7OBMYFfXsS0lXcDi0fDjDtgxzeU05XQYxtXdwcHWk/rNnaYzQppX0yUjqFsIB QlZaytxFuk+sTYQVoqbbYVclJb53bVAGTcwNgbYUJfLaVWLecoILpqLthD4j0gKSqnDU 4+hF7m/LBqWcb0M/8RW5igiSrgOzkA7iyVUHT6aLEFsuv24vB1gsKVAl6cGg9oUGA99X QXwg== X-Gm-Message-State: AOJu0YwpLg5n7uyPtItUoC3Refl/16No1REDcEJcCjZNYFXHOhoL0wSl 2My+g3a8yLx4h9EqhVWkg8h2fwZ0hhFT5+iPwS6fkVClMHr4K+YN1RM8D05JNErYsPc241d0kwe 6 X-Google-Smtp-Source: AGHT+IHTYY8GzdE0qmNDJxvItQemDRbL29ynSoDmyBNelZusPUxcRSkkL/2BVEd5AsQ0xPkg8MwT3Q== X-Received: by 2002:a05:690c:6a89:b0:64b:6559:5d71 with SMTP id 00721157ae682-67a09d5fabemr10184417b3.32.1722022621870; Fri, 26 Jul 2024 12:37:01 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756c44db44sm9849157b3.144.2024.07.26.12.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:01 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 23/46] btrfs: convert extent_write_locked_range to take a folio Date: Fri, 26 Jul 2024 15:36:10 -0400 Message-ID: <440fde6ddd6623c84c938bb41ae9e2c3a0f9ed97.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This mostly uses folios, convert it to take a folio instead and update the callers to pass in the folio. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 4 ++-- fs/btrfs/extent_io.h | 2 +- fs/btrfs/inode.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 6036fd6b9b79..1faadf903e00 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2275,7 +2275,7 @@ static int extent_write_cache_pages(struct address_space *mapping, * already been ran (aka, ordered extent inserted) and all pages are still * locked. */ -void extent_write_locked_range(struct inode *inode, const struct page *locked_page, +void extent_write_locked_range(struct inode *inode, const struct folio *locked_folio, u64 start, u64 end, struct writeback_control *wbc, bool pages_dirty) { @@ -2317,7 +2317,7 @@ void extent_write_locked_range(struct inode *inode, const struct page *locked_pa } ASSERT(folio_test_locked(folio)); - if (pages_dirty && &folio->page != locked_page) + if (pages_dirty && folio != locked_folio) ASSERT(folio_test_dirty(folio)); ret = __extent_writepage_io(BTRFS_I(inode), folio, cur, cur_len, diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 5d36031578ff..b38460279b99 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -240,7 +240,7 @@ bool try_release_extent_mapping(struct page *page, gfp_t mask); int try_release_extent_buffer(struct page *page); int btrfs_read_folio(struct file *file, struct folio *folio); -void extent_write_locked_range(struct inode *inode, const struct page *locked_page, +void extent_write_locked_range(struct inode *inode, const struct folio *locked_folio, u64 start, u64 end, struct writeback_control *wbc, bool pages_dirty); int btrfs_writepages(struct address_space *mapping, struct writeback_control *wbc); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 199f783680e2..0b44a250e5b8 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1758,7 +1758,8 @@ static noinline int run_delalloc_cow(struct btrfs_inode *inode, true, false); if (ret) return ret; - extent_write_locked_range(&inode->vfs_inode, locked_page, start, + extent_write_locked_range(&inode->vfs_inode, + page_folio(locked_page), start, done_offset, wbc, pages_dirty); start = done_offset + 1; } From patchwork Fri Jul 26 19:36:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743092 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 0E38114A4D9 for ; Fri, 26 Jul 2024 19:37:03 +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=1722022625; cv=none; b=minYKHEB8MxrDvTlLLcj19SbZ0kX5G1mrfiVU8Ta1lwyI0S5dZQSWqSDdL6X6vDpwUncYC/7H8fjKagTKY4aw9gM1OIciJ5Vui0nwGnurOLGea5I8RsX1dhFpKzq+Vs99LxdSF6238xfWGV2obYf/SFO5u3LIW0/jHcnBJMtO1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022625; c=relaxed/simple; bh=G5QmXgbeZN7sW1CiPFlxbcRq8RJ/9s+FS97PZ8BDM4M=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SUUEkUmbJ0b5kkVBkixan3hMYdNjJbTfqFFudxuer+1dKiNp9Sh3yEqT65MXzUKo3vumCr21XlgLejzNiExsrKTe8w2MR17vcf4DMbj7lIl9pJlX18Of8E0mne6/ZCE6g0GevLvcC3SseiTErqvdJb/M2jMqqQ1ZiouvPb06rnw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=ChlF9Ck3; arc=none smtp.client-ip=209.85.128.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="ChlF9Ck3" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-65f7bd30546so309327b3.1 for ; Fri, 26 Jul 2024 12:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022623; x=1722627423; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=CAl883lvg1XhBMGcxrpSf80GLO9WAjlmZP6Mki4ERcs=; b=ChlF9Ck3yskJyfChDaM/l5nanSu0xv57VlhNNT5cN6881P028g3/xqw1r9TVbcrr4T YsfdC2GTa1YNIli+mJsea/bJHhK4eEwOJc8rfadm5o2sT+MCUt0dzb695JoFerYxJR0s mVOhFWNu3lvVINnIk57lAFGOmQLnLVIZ+c/Rt7mPhwH/JyLkxJsW/Pr9UQ2i5IvzUB0y TJLpWEt+8zJJ3ptRAKWu3G/MkOH2qvvylznOGQNKQMqtwRbhIE2T/U3jChULTE1ZFaED TxRKwVon4fxk9Y2GGDfOQKwaqd10LOlOxVtjwhB3QWeFlPVa++o1RN6/9c8AfzT7Y7PL aitw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022623; x=1722627423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CAl883lvg1XhBMGcxrpSf80GLO9WAjlmZP6Mki4ERcs=; b=jWplKiV7XhmaWvu2zqrK8tKK3/ZnZAFnLToguymRNcPTvvc4X2X63nJVhfEEbXhG4N JKMf49ZJSsUh+H4fhTN6BJKQVek+e7+AryUf65w8gvXCJMmtcpAYjDfZIgdsT7FM+IG4 tSMQ8GW8jYcoxD4zSKYYlUOScMTrOcdNirR7N/R7cHnDMia8+UnVVUvJU/RBC/Fx6tqR DOnyeeedYKcnFQ+6AFmZzNWKBykBpQkM92dL7Sch6mkTstRv2GbY2H4/Q/oHxUAYEf5x 3FpqAnoGtskjcvISGpO/ahEE/bPtZyTVFFSicJYKn+FYby4pWwuT7vSZEQu3EQQepUID 1UDA== X-Gm-Message-State: AOJu0YzUBqMTT6hM/LdmIxFLCMQwHEeBLPM9KZFHcLtD1FIr1aDWVds/ ZitRJI0pKkLKde0MGJsMhXkiSMJr0X99CsXK86ByWxJJiOyqy+K3lsJ/yx2dlCLNKrZcCGHOAF9 T X-Google-Smtp-Source: AGHT+IFlp+s5uPPcrU5scxQnYuwRuSI/3N3ts/PEWCqCIy78q8oZ9OoFLX52GvooCKNBi8CeyKzR+Q== X-Received: by 2002:a0d:d003:0:b0:64b:b7e:3313 with SMTP id 00721157ae682-67a2aa8d551mr5943577b3.13.1722022622827; Fri, 26 Jul 2024 12:37:02 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756795e987sm9925517b3.39.2024.07.26.12.37.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:02 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 24/46] btrfs: convert run_delalloc_cow to take a folio Date: Fri, 26 Jul 2024 15:36:11 -0400 Message-ID: <73b6c02da1433a120f243616086e6ae751893b7e.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We pass the folio into extent_write_locked_range, go ahead and take a folio to pass along, and update the callers to pass in a folio. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0b44a250e5b8..db0aa7ece99c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -116,7 +116,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr); static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback); static noinline int run_delalloc_cow(struct btrfs_inode *inode, - struct page *locked_page, u64 start, + struct folio *locked_folio, u64 start, u64 end, struct writeback_control *wbc, bool pages_dirty); @@ -1135,7 +1135,8 @@ static void submit_uncompressed_range(struct btrfs_inode *inode, }; wbc_attach_fdatawrite_inode(&wbc, &inode->vfs_inode); - ret = run_delalloc_cow(inode, locked_page, start, end, &wbc, false); + ret = run_delalloc_cow(inode, page_folio(locked_page), start, end, + &wbc, false); wbc_detach_inode(&wbc); if (ret < 0) { btrfs_cleanup_ordered_extents(inode, locked_page, start, end - start + 1); @@ -1746,7 +1747,7 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode, * covered by the range. */ static noinline int run_delalloc_cow(struct btrfs_inode *inode, - struct page *locked_page, u64 start, + struct folio *locked_folio, u64 start, u64 end, struct writeback_control *wbc, bool pages_dirty) { @@ -1754,13 +1755,12 @@ static noinline int run_delalloc_cow(struct btrfs_inode *inode, int ret; while (start <= end) { - ret = cow_file_range(inode, locked_page, start, end, &done_offset, - true, false); + ret = cow_file_range(inode, &locked_folio->page, start, end, + &done_offset, true, false); if (ret) return ret; - extent_write_locked_range(&inode->vfs_inode, - page_folio(locked_page), start, - done_offset, wbc, pages_dirty); + extent_write_locked_range(&inode->vfs_inode, locked_folio, + start, done_offset, wbc, pages_dirty); start = done_offset + 1; } @@ -2311,8 +2311,8 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page return 1; if (zoned) - ret = run_delalloc_cow(inode, locked_page, start, end, wbc, - true); + ret = run_delalloc_cow(inode, page_folio(locked_page), start, + end, wbc, true); else ret = cow_file_range(inode, locked_page, start, end, NULL, false, false); From patchwork Fri Jul 26 19:36:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743093 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 C431614A62A for ; Fri, 26 Jul 2024 19:37:04 +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=1722022626; cv=none; b=ph/1rTM5LauJQR8PSMaXvbhSboVIPRTsgHQItirxemJCbW0JsPYJICU+mhzbYj0/mMTKvQNtkNHrVMBfc80EZ97p/l2B81X2BmQaov76nrKYlW0vqBzIemG0Xp7xntTT7ziN/eN2JUZCfpikvvI7QORy+PSKZPKcvpKYDykEjus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022626; c=relaxed/simple; bh=DKNY+OoVb580grAKIdaIydw8WKgmgCxEXp4/VUPnv54=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FU32l1eAOrm3+UMUl+iKyV6w+YhhOfBlX7CxIGT9fsapBcIfBr5p72MKVT/F/yydzoi46Gu9XWk7ptArNTGRkz1pqZ1UuhdeL4tmw9T7KkJU9i8v1UhP0ghJeK6uATg3fmsGjv1IthjaWhuifdTWI9xvoh3HPaZeoUUct7pGVyQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=28Vfce2U; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="28Vfce2U" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-66526e430e0so375347b3.2 for ; Fri, 26 Jul 2024 12:37:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022624; x=1722627424; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=R8mn4fgfp5hpDD5/ffNe5knH/SCnTcqUd//Oyk8i9TQ=; b=28Vfce2UJ/vSerZ3dITWE1H5a95QsjUsFjaWUYaMD1A38jHlY8qS3vnzyrY4SoCOWw DBHLQgO3+zQw0Am7+/cKfxfGti5BEdmixCMrA5AaYD5Ke4sgo8faWJD/nWokygzo4bIn ubh2+9UrPsFSHRh+ysce4JSdGy6WBlbPBN1xOSZH54leIU9VOSsobeEJ26KNgT04TEQ0 X6PlFzBa2CnWPqIP8SAzf+f8ermaFtmZ8fYsuP0VGpGl4u//ocWYDLU7LebDOgz4n5x/ hN3tXmfMHippIDk74P0UswDb/G8G5QvjLVUa6lT6NYeZ/uJT9MveXrGOcbphE0Duuj33 Pueg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022624; x=1722627424; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R8mn4fgfp5hpDD5/ffNe5knH/SCnTcqUd//Oyk8i9TQ=; b=hFeOwdLSJ9cJYyo1QCW05J1lE3v8PURCn8MrZIK6EA/TdzJdHxi5u2bhiAeFcMLsex RPMA9npPelyWxtpzveW8+t73ZoLs6PwzXwgo8mFuls3IFwdC3g4YrbTjV41E8hmV9728 6LHF3XC0XzKsvJVUpHVAOJzN8Nr3woAL78RbRSfn7Eh2l9pEAiaVrXyeio30/lhRi0/v u7vnzCT1fz0zgsOQ3wNKm4cyQuJtVqn2MC7B4wLTs2N4rl/zEEu1Uz4nm9XFxFzvRRVz sprxEnDsUuVwFTBvVUcpvlz7p601O5iNu1BxNO23lskr2aKp+PZX+LwD8N5bJtdp0Ye5 66mQ== X-Gm-Message-State: AOJu0YzH/Z54eW0eLfKeBUVY1eDasP1GQuGqo8MNeDJj9kMm/QNVepik ZYOWVPrwOJvibFs3SIFTqoBD38jVfjjEEjWdzq3T40JawLkXmRtIjjY8kZfb/7cUrwOOoZ17lDY 7 X-Google-Smtp-Source: AGHT+IE/P8eEePxjfRac2HxHbLoF3mbP+rG3J1p1ZpDrEAPuVgPqCQOGLbEjx0DWEJl9OHdUD5HUTg== X-Received: by 2002:a81:6e46:0:b0:62f:b04c:2442 with SMTP id 00721157ae682-67a051e835emr10570427b3.7.1722022623769; Fri, 26 Jul 2024 12:37:03 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67566dd91ecsm10015777b3.17.2024.07.26.12.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:03 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 25/46] btrfs: convert cow_file_range_inline to take a folio Date: Fri, 26 Jul 2024 15:36:12 -0400 Message-ID: <95c76149c7094019e8879547df1c642cfce36511.1722022376.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that we want the folio in this function, convert it to take a folio directly and use that. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index db0aa7ece99c..7f2875c99883 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -715,7 +715,7 @@ static noinline int __cow_file_range_inline(struct btrfs_inode *inode, u64 offse } static noinline int cow_file_range_inline(struct btrfs_inode *inode, - struct page *locked_page, + struct folio *locked_folio, u64 offset, u64 end, size_t compressed_size, int compress_type, @@ -741,10 +741,9 @@ static noinline int cow_file_range_inline(struct btrfs_inode *inode, } if (ret == 0) - locked_page = NULL; + locked_folio = NULL; - extent_clear_unlock_delalloc(inode, offset, end, - page_folio(locked_page), &cached, + extent_clear_unlock_delalloc(inode, offset, end, locked_folio, &cached, clear_flags, PAGE_UNLOCK | PAGE_START_WRITEBACK | PAGE_END_WRITEBACK); return ret; @@ -1365,8 +1364,9 @@ static noinline int cow_file_range(struct btrfs_inode *inode, if (!no_inline) { /* lets try to make an inline extent */ - ret = cow_file_range_inline(inode, locked_page, start, end, 0, - BTRFS_COMPRESS_NONE, NULL, false); + ret = cow_file_range_inline(inode, page_folio(locked_page), + start, end, 0, BTRFS_COMPRESS_NONE, + NULL, false); if (ret <= 0) { /* * We succeeded, return 1 so the caller knows we're done From patchwork Fri Jul 26 19:36:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743094 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 078B314B07E for ; Fri, 26 Jul 2024 19:37:05 +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=1722022627; cv=none; b=JvBzfbHz4FnL2XNlyEiIhiKmdz55eFEwG9qlj74+3smJLfmr+wfEuKhl1RzwIpDPu/+akB6MFbILw+bx9PdeSA8MArCbJXRjcbHREE8ymlnyo3eNgpaNgsZnngkjwJnZKJp9B+hy6yqaRB9IK6SZ6pOtPIb43UiGtYaKZ22i+IM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022627; c=relaxed/simple; bh=vXyvCy9R3VXC6mPRxu++SmDUun7t57RrlhAOIT8TxcY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PRvKl9wzd6JYqPd2rQR4mesP5cEGHQVKTMPlHu1Q+m6m00iShU6lEo4UpRoeoSEKDCUdogQBJqIMUJ3nECz786AVOtHTdOmAbQqBHhtds83vFO1vdHcxNe/MNOr2pMbSS/T4udCBofpAgJ0ekOGL3cwCvD9OvHdiYAguwYW1wfo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=j0on9Cx+; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="j0on9Cx+" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-66ca536621cso369297b3.3 for ; Fri, 26 Jul 2024 12:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022625; x=1722627425; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jhWXIGntr/PMq1tVx+zlZ/pm4fOlxeQXlCf+Q9Tbx04=; b=j0on9Cx+KdTKgL8QqR5BwDkgMLnlC7tee2miIWNVrsmVytYxqF8S6nGx1IFC5Bkv3d wHfQCINvnuMs+0nOQ0RW4frwYJN0Sp90prMZ+htnuNofWXcEoeI2lhOAGnkMAtRvTM/Q tLKChpgJFwXJmaaK7bnvH/3MhLNG+FimCyf4Rw+Cm/8HFU43vGlQsncn6Al5mljCAeRa CXBKzT+RIrMz9oBbRPXqYjnqimLv/UvoxjV49QvBmOImKABmkHaMNmEz+Z5mqlGm+KrL jQP6uCN524MjREIb0KO4Ad6K5WPJ+Bg9VyEjdHwzrG998jKKTyn6aBNSMKKxntpEcG/l f/DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022625; x=1722627425; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jhWXIGntr/PMq1tVx+zlZ/pm4fOlxeQXlCf+Q9Tbx04=; b=mzJnXQXR1NBvsz+ypIJOH1T9gIA6AuC4jllALFSChbtt49ng16mOWYh+LbeZTG1QaX SU0CZoqcBQRXbigxC4oTB2NeYFtzV00kyldwLg6LCK13mV7hJ9gPCaisI2L0qS11Ob9m PQrm4rL1RbHGnbKbRhLJe9LiXaVA2Lwgo9Ku4h53o5t3kRh69cA7i3HeL7B5KVz3l7uu 98BZbZkBKAnk/cK+AtjpqVuJ1rBw3kyPya80wYwU4wQHsh21DRIgf3FwAiwudVeCW8Wl WaJjNfB4m7KMuE963J/vld3X7zTyn7ghmuNDetIzMFaPgs1p3J41W+nUui1bZh6MFOiG Rk/w== X-Gm-Message-State: AOJu0YzAm+UW+hN8GcrccN9KtZkhNK/QlRlmbwAhTQneItbFL/CMTqlA yxajdN6bt99y7+YOI9K0xyTP8xdr2dvAcyttAOGXJhLCdiI+rXPvWosGs9gzd3nK4x0KdXlFYdW T X-Google-Smtp-Source: AGHT+IGTplk3+d2nGjdAOPwplc+F9StrfP+fcANMVsx26/93lRxO1S3GgEgyBBYJ0XZoYM7huanNXQ== X-Received: by 2002:a05:690c:3346:b0:632:7161:d16c with SMTP id 00721157ae682-67a090a5e7dmr9539897b3.28.1722022624823; Fri, 26 Jul 2024 12:37:04 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756b024a59sm9929857b3.92.2024.07.26.12.37.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:04 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 26/46] btrfs: convert cow_file_range to take a folio Date: Fri, 26 Jul 2024 15:36:13 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert this to take a folio and pass it into all of the various cleanup functions. Update the callers to pass in a folio instead. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 7f2875c99883..9fc15b881dba 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1307,21 +1307,21 @@ u64 btrfs_get_extent_allocation_hint(struct btrfs_inode *inode, u64 start, * allocate extents on disk for the range, and create ordered data structs * in ram to track those extents. * - * locked_page is the page that writepage had locked already. We use + * locked_folio is the folio that writepage had locked already. We use * it to make sure we don't do extra locks or unlocks. * - * When this function fails, it unlocks all pages except @locked_page. + * When this function fails, it unlocks all pages except @locked_folio. * * When this function successfully creates an inline extent, it returns 1 and - * unlocks all pages including locked_page and starts I/O on them. - * (In reality inline extents are limited to a single page, so locked_page is + * unlocks all pages including locked_folio and starts I/O on them. + * (In reality inline extents are limited to a single page, so locked_folio is * the only page handled anyway). * * When this function succeed and creates a normal extent, the page locking * status depends on the passed in flags: * * - If @keep_locked is set, all pages are kept locked. - * - Else all pages except for @locked_page are unlocked. + * - Else all pages except for @locked_folio are unlocked. * * When a failure happens in the second or later iteration of the * while-loop, the ordered extents created in previous iterations are kept @@ -1330,8 +1330,8 @@ u64 btrfs_get_extent_allocation_hint(struct btrfs_inode *inode, u64 start, * example. */ static noinline int cow_file_range(struct btrfs_inode *inode, - struct page *locked_page, u64 start, u64 end, - u64 *done_offset, + struct folio *locked_folio, u64 start, + u64 end, u64 *done_offset, bool keep_locked, bool no_inline) { struct btrfs_root *root = inode->root; @@ -1364,9 +1364,8 @@ static noinline int cow_file_range(struct btrfs_inode *inode, if (!no_inline) { /* lets try to make an inline extent */ - ret = cow_file_range_inline(inode, page_folio(locked_page), - start, end, 0, BTRFS_COMPRESS_NONE, - NULL, false); + ret = cow_file_range_inline(inode, locked_folio, start, end, 0, + BTRFS_COMPRESS_NONE, NULL, false); if (ret <= 0) { /* * We succeeded, return 1 so the caller knows we're done @@ -1502,7 +1501,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode, page_ops |= PAGE_SET_ORDERED; extent_clear_unlock_delalloc(inode, start, start + ram_size - 1, - page_folio(locked_page), &cached, + locked_folio, &cached, EXTENT_LOCKED | EXTENT_DELALLOC, page_ops); if (num_bytes < cur_alloc_size) @@ -1555,14 +1554,13 @@ static noinline int cow_file_range(struct btrfs_inode *inode, * function. * * However, in case of @keep_locked, we still need to unlock the pages - * (except @locked_page) to ensure all the pages are unlocked. + * (except @locked_folio) to ensure all the pages are unlocked. */ if (keep_locked && orig_start < start) { - if (!locked_page) + if (!locked_folio) mapping_set_error(inode->vfs_inode.i_mapping, ret); extent_clear_unlock_delalloc(inode, orig_start, start - 1, - page_folio(locked_page), NULL, 0, - page_ops); + locked_folio, NULL, 0, page_ops); } /* @@ -1585,8 +1583,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode, if (extent_reserved) { extent_clear_unlock_delalloc(inode, start, start + cur_alloc_size - 1, - page_folio(locked_page), &cached, - clear_bits, + locked_folio, &cached, clear_bits, page_ops); btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL); start += cur_alloc_size; @@ -1600,9 +1597,8 @@ static noinline int cow_file_range(struct btrfs_inode *inode, */ if (start < end) { clear_bits |= EXTENT_CLEAR_DATA_RESV; - extent_clear_unlock_delalloc(inode, start, end, - page_folio(locked_page), &cached, - clear_bits, page_ops); + extent_clear_unlock_delalloc(inode, start, end, locked_folio, + &cached, clear_bits, page_ops); btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL); } return ret; @@ -1755,7 +1751,7 @@ static noinline int run_delalloc_cow(struct btrfs_inode *inode, int ret; while (start <= end) { - ret = cow_file_range(inode, &locked_folio->page, start, end, + ret = cow_file_range(inode, locked_folio, start, end, &done_offset, true, false); if (ret) return ret; @@ -1837,7 +1833,8 @@ static int fallback_to_cow(struct btrfs_inode *inode, struct page *locked_page, * is written out and unlocked directly and a normal NOCOW extent * doesn't work. */ - ret = cow_file_range(inode, locked_page, start, end, NULL, false, true); + ret = cow_file_range(inode, page_folio(locked_page), start, end, NULL, + false, true); ASSERT(ret != 1); return ret; } @@ -2314,8 +2311,8 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page ret = run_delalloc_cow(inode, page_folio(locked_page), start, end, wbc, true); else - ret = cow_file_range(inode, locked_page, start, end, NULL, - false, false); + ret = cow_file_range(inode, page_folio(locked_page), start, end, + NULL, false, false); out: if (ret < 0) From patchwork Fri Jul 26 19:36:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743095 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 5A2F24AEE9 for ; Fri, 26 Jul 2024 19:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022628; cv=none; b=TFIWMZPlrctQSHk8cbvw5iv+umueO5MxhAWFbiG/14AzKo7vs8d0/k3uyatNWY+2j/GNknxtLVK/mt/gsc+C8z2llM68PPbkN8oeB76I1OueKKtvHUf2YGM0uPcZ1EpChCkB1B/saEjtfG6kbvYtaUVGj/lwdsr3j83to//MaTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022628; c=relaxed/simple; bh=BE5n0wzzNs2giZL0UI05zMNv8ItKz0Zm+10eLjTjdyE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i6wedcgNQmESWKV+iirs3v+AsbnVJqOVlhjwHFkd2+nSFTsbm5RHyG5APn52GlWHOoRFFPoN2zYbrDqGzucKTDpIIeBZ3+NBPvE53pNvmF3XgEwJrcxOdrR8KzfOywz9cC93XZ188LIqItKp0uOfpkUYozOfkcAgV4Ij0K8LXAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=VMIJeQST; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="VMIJeQST" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-65fe1239f12so564837b3.0 for ; Fri, 26 Jul 2024 12:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022626; x=1722627426; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ymN4eCpoeNZacIzt3rOcGtpA4GpPoFMo44PJbXvbV4U=; b=VMIJeQSTp9AHjVoJ08hSlgWlL45ShUACxVgQDCUXXnG0EQ96evJQ5Jtu8fr6Ag1Lz2 cUfaYCFB/51OvH5R24m6gx2hn86XIDW4YTIrIWjy3v8YOF7FJk58crWT5KsSLphc/mPH huIWPwwGVgIyiBSMZCfCSHFRP/+huio9MSWUDm97Gc52I+GVXYMZaxeFOGYHxkunw+yw tif29gZD0TCcMy/VYxy7OcZdMQ6izVAQZvOv281hyac5dRu5g2w0GqYDNZBd+9PfPSz8 oONriBx2lSHhzx7gB7UQeJfGw+H9zjcedh1yeBItjDX81KrquM/4TL+qQwzVk72bLcXY UWlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022626; x=1722627426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ymN4eCpoeNZacIzt3rOcGtpA4GpPoFMo44PJbXvbV4U=; b=OUF2YDhz5HyX5qLaN2mYZ5ZCWbyjaOI376V8GJk/Yboa2ma4KCf/yCaBWwliD91EO0 m2rU9Ugn1I/g/7oSvZMXye4o6dREyTW/5RUYNJ66M/ew9y9C+VmqvebDvgdWKDS/KOjy X8hceKzJstMXpAPoBSzee59xXlujhYr3nlxhClyO1kF1gxQfRcAIVrApa7WjCvRhScKn ITtqMLf25J+zVKGHarhOuk+GirA8PI7fKFMgeLeK1xhTmIbnE6gM50W1W0VA6xHEcU9r +i7ajSLWGWPMjRExbDFwJ4+7itehSeM2HvIxI0MeIz41hhwoUOX0MjjWtrg24hHfYPAl 06/A== X-Gm-Message-State: AOJu0Yzg/Ow5JsY2ZrSP7tWY6bQicOsAL/CJNtQYRLwoWuAsij42yPt3 bPIIUaGuXXK20DZRK4nSFKStMf0NHzTlQuMyQtCzQBPdr6iIsxhTQXbzK+i+ZtSs9TpflgQyd7m U X-Google-Smtp-Source: AGHT+IEspBnmO1sJcSKORGUxJTZC2xCc328MpUMGGBrVgm7AFRQc2OWQk7I6eEN2sKkt75XN0xWfxw== X-Received: by 2002:a05:690c:6d89:b0:66a:76cf:f312 with SMTP id 00721157ae682-67a05b949bemr9666127b3.11.1722022626277; Fri, 26 Jul 2024 12:37:06 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756b1193basm10024997b3.95.2024.07.26.12.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:05 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 27/46] btrfs: convert fallback_to_cow to take a folio Date: Fri, 26 Jul 2024 15:36:14 -0400 Message-ID: <5bbc066b26be3d629474be5f76df606bd61d1a84.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 With this we can pass the folio directly into cow_file_range(). Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9fc15b881dba..d8ff1bb188e1 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1763,8 +1763,9 @@ static noinline int run_delalloc_cow(struct btrfs_inode *inode, return 1; } -static int fallback_to_cow(struct btrfs_inode *inode, struct page *locked_page, - const u64 start, const u64 end) +static int fallback_to_cow(struct btrfs_inode *inode, + struct folio *locked_folio, const u64 start, + const u64 end) { const bool is_space_ino = btrfs_is_free_space_inode(inode); const bool is_reloc_ino = btrfs_is_data_reloc_root(inode->root); @@ -1833,8 +1834,8 @@ static int fallback_to_cow(struct btrfs_inode *inode, struct page *locked_page, * is written out and unlocked directly and a normal NOCOW extent * doesn't work. */ - ret = cow_file_range(inode, page_folio(locked_page), start, end, NULL, - false, true); + ret = cow_file_range(inode, locked_folio, start, end, NULL, false, + true); ASSERT(ret != 1); return ret; } @@ -2151,7 +2152,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, * NOCOW, following one which needs to be COW'ed */ if (cow_start != (u64)-1) { - ret = fallback_to_cow(inode, locked_page, + ret = fallback_to_cow(inode, page_folio(locked_page), cow_start, found_key.offset - 1); cow_start = (u64)-1; if (ret) { @@ -2230,7 +2231,8 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, if (cow_start != (u64)-1) { cur_offset = end; - ret = fallback_to_cow(inode, locked_page, cow_start, end); + ret = fallback_to_cow(inode, page_folio(locked_page), cow_start, + end); cow_start = (u64)-1; if (ret) goto error; From patchwork Fri Jul 26 19:36:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743096 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 4E6B014D452 for ; Fri, 26 Jul 2024 19:37:08 +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=1722022629; cv=none; b=MikGo+mtqk7n4pFQt875z66gvRWMlWLzeiS6K9Udf8/yAu/lkigRZj0YlG/0JiMgxhdFvGW9mwTcv1nrE2sUG3wcnqS3ksSxoVR/LGR0ZSrZfkmXJJNX5/BVIzlUOdekDhFPin4FuHwhEmjttOVETI3lFEsvm+2ufZlFA0OuqLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022629; c=relaxed/simple; bh=Lbzscw7kPcK8mkNODc2TNedVk7EESONz8/mxZ7ackbw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YL0w0vTGUw9+g4gs+ufe4ANtRu3QOZOPkWhTgE10ShrAybeJLlFYrUROH3dFNabh0HqzSkyGGQ8GlRNcK0+klaFYmIoBspYeRnA8fCTO4T6AaqKsHw6EoEftmKgIHYic3McsdChRsjr0c99hQQaJQZ8F6jqLbh06i47ep7Xcc2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=XKx10GLt; arc=none smtp.client-ip=209.85.128.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="XKx10GLt" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-65f9708c50dso380687b3.2 for ; Fri, 26 Jul 2024 12:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022627; x=1722627427; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=L96GEfBJihYonB/f3nQJxYnSMQmpL2icIBjt4xmg9mE=; b=XKx10GLtiDvBwNxiQDJZUrYp+oqueu92RLjQzWgB4SGHT5iMTpULVTdkOLIea9bzwR Q0e/BFP1SlnXdEhv5wr1EjL8+xtHc154nycWmby6QRBvrizW9XIFauxBVrjwQrD4PQaV g8BBbthKAV5Qq7I89A8485OIbvnWZb92F+uM7x+KeJfnw2ZzciQEoPtSSjMMXy2UH4oI t20CK4p8ITcZWm4DdDhYLxsGTK10FhXZGaqtCwL53FYmGkebziKWnCySvh126Km7TKd+ gvO6MTDdcd/oOfbiYcvHjUUtYuV86ZSXqfFrgjBXrUVz5Ene29QzGHtEJTslX4DqcacX TKHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022627; x=1722627427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L96GEfBJihYonB/f3nQJxYnSMQmpL2icIBjt4xmg9mE=; b=t8HuiNQE0s55Oe44yjAmmMglmm49IDXhDhdIgLCNDnh0LCgZPzVqG6SWDBf4qey8ZG lI9TKkg7tcWlWgf/wxeMZan9KdnBIf3gdFohYYPzVWwnamTxOi9IFlBVyTVWxGBp/GXn Ylq+UV+rWDXrRc8WoFjntf9zoDI2A43VdRN+cAAIsiiaFCJsbFbgt546tHnnj3cTaq6u PYOJPtPAemCrc0157R+2B+Wlc+N14TxZBJR9wQJVpe3m4bX5ORcSgdEpto2N86Zuq0lp PJaQGJnJGFXoAZzzo4ca9GDnEiRdoKG7pVaNMTZuoNEGXxsphulprz6+hYnfAyW1Ydmo blow== X-Gm-Message-State: AOJu0YyOmDHDDbJlqUQrTiK2a6kPZptmFB/f+yN2OjwvhIdrFwB/542l pPflBMlUhTByaBlpM6u11jVDXcoP/BP0BZ7GVg5Srla6nBwlErxREnc6Vk1ty+JW0vDt9463J6O A X-Google-Smtp-Source: AGHT+IH7Ff8GwzE2cYfgqwSfd2bSVybcPwFwCi3snf4klVFSgbj+voxWYYrZz8XWz3qY4ORzUUErfg== X-Received: by 2002:a05:690c:6d8a:b0:64a:489c:4fbc with SMTP id 00721157ae682-67a0a8f4c59mr9438277b3.46.1722022627334; Fri, 26 Jul 2024 12:37:07 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67566dd90fesm9841827b3.20.2024.07.26.12.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:07 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 28/46] btrfs: convert run_delalloc_nocow to take a folio Date: Fri, 26 Jul 2024 15:36:15 -0400 Message-ID: <617a72ec73fd6c1b850ab36fde82e53075c03c38.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now all of the functions that use locked_page in run_delalloc_nocow take a folio, update it to take a folio and update the caller. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d8ff1bb188e1..a95bbe602a90 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1989,7 +1989,7 @@ static int can_nocow_file_extent(struct btrfs_path *path, * blocks on disk */ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, - struct page *locked_page, + struct folio *locked_folio, const u64 start, const u64 end) { struct btrfs_fs_info *fs_info = inode->root->fs_info; @@ -2152,8 +2152,8 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, * NOCOW, following one which needs to be COW'ed */ if (cow_start != (u64)-1) { - ret = fallback_to_cow(inode, page_folio(locked_page), - cow_start, found_key.offset - 1); + ret = fallback_to_cow(inode, locked_folio, cow_start, + found_key.offset - 1); cow_start = (u64)-1; if (ret) { btrfs_dec_nocow_writers(nocow_bg); @@ -2208,8 +2208,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, btrfs_put_ordered_extent(ordered); extent_clear_unlock_delalloc(inode, cur_offset, nocow_end, - page_folio(locked_page), - &cached_state, + locked_folio, &cached_state, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_CLEAR_DATA_RESV, PAGE_UNLOCK | PAGE_SET_ORDERED); @@ -2231,8 +2230,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, if (cow_start != (u64)-1) { cur_offset = end; - ret = fallback_to_cow(inode, page_folio(locked_page), cow_start, - end); + ret = fallback_to_cow(inode, locked_folio, cow_start, end); cow_start = (u64)-1; if (ret) goto error; @@ -2259,7 +2257,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, lock_extent(&inode->io_tree, cur_offset, end, &cached); extent_clear_unlock_delalloc(inode, cur_offset, end, - page_folio(locked_page), &cached, + locked_folio, &cached, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING, PAGE_UNLOCK | @@ -2300,7 +2298,8 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page start >= page_offset(locked_page) + PAGE_SIZE)); if (should_nocow(inode, start, end)) { - ret = run_delalloc_nocow(inode, locked_page, start, end); + ret = run_delalloc_nocow(inode, page_folio(locked_page), start, + end); goto out; } From patchwork Fri Jul 26 19:36:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743098 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.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 5DDE214EC5B for ; Fri, 26 Jul 2024 19:37:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022631; cv=none; b=H8FyPd+uktnMe2hJ8ecSv2TT23OnHMnx1fbHWb5uLbq0ONT3R8fCXytCl4u24EibctBGO8PB4RVY14FHeK8b6g+RQlX2DDcBoyLjRbeUiC3k0aTzKY/C24vrH/AJ+Ivhep+pcBh+NytgaCmEnTgCO+UarOZagrmm3UeElO2UQlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022631; c=relaxed/simple; bh=5G3U3TSmXg9RnPpmk+o2t+UGa6n6SKoz9RZLNzI3E0c=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DwgKxoExmGJN2mmjSmwq16Jby7CwR0GwGA8BJjKhGXcMkZEHjv4AQdo0dDSFhA82aoEYZ2dQrtT4oF/TY2bNGQRqEU+cp1G1xz0N29ygwqEIxRZS5kQB2x8kwp03tbavy0Bw9hFRVF+cIMWV6enFkVJsPr0qKtLvznkZ3wnVkUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=xVCgmUzo; arc=none smtp.client-ip=209.85.219.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="xVCgmUzo" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e08724b2a08so42284276.1 for ; Fri, 26 Jul 2024 12:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022628; x=1722627428; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FNZL01EEV5y58njT3yEegxRNXw4HWHN23T70fkxL78k=; b=xVCgmUzolCnEmd2NUPmiAeeDR45Do6Iyaq866ho2eD8JxuRRSnXZHRfwqNmo7bs143 y2WSwED9PO4UmZAFKArriKSM+EqHnVzH1fyRM4zOE9HmagrDsPvJrykZeGCWU6A7LUX2 Q3/aJ3siYrO+WME9D2VMW96icKChYnLxjSdhYaZWJhKFJAxTlid5S4s3PqZ1XZs1+NDn lFMRODVsZQg3fQlPWEqgUJ8An8nRc2UXKnaHCJRA+oV1uJO8Z1+nCCgY7mgIwshGqND6 PyXdd0iTe946rqT1Ov23JtT7RB8oDlTbWaxYrRLaWrd/LOH0OjGGAPk/3kNydAFvvQBK 2Ydw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022628; x=1722627428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FNZL01EEV5y58njT3yEegxRNXw4HWHN23T70fkxL78k=; b=mkzgJZEHsQDO2h8bm6OctVngh9tsFeOhANh2/sbcKCZ3xgANEJRsPhxwKvJ1Jyo2Jq YMQpVvHULqb0NasphYgb5e04OZ8GJ+pg3fen6LUKIx86rl6qtZ1Wb93qbAQmeQMZmu8m GrjHi+9v/sLjc0ODrpiBJhpm8CRnklpZOi5UclgY/FcHCB3Z6fjeMXrul4O/b8SmTsSk 9Sj6dFRZ0qduWKiKpeBltdQ+9zKtCIfQswo011vXF1jyFBAY9hcTPr+FL8QiwEanRB4q yXt/fX2a7WGd36jY8mN16/zXGaB4UFXVaY862OL6I/n91vNCJBCjdfJp5uNj1MUQN/AS /XDg== X-Gm-Message-State: AOJu0YyMws1BaFgX0tmBmUgLRqQj3b8ZOKSo//8PtzXiW9KLtSJ8l/iS CNwAPEqwmqXvUfmyDUerJwisQgpxle3ytx/2zAsoNKUCCSxs78O3GFS2CI0LD28gYzEmIzKcGTk s X-Google-Smtp-Source: AGHT+IHvBRN35YhK0a8IV+BvKDIwOsZjdr3S4AfnnS42YkYqV0NXTgVmo7roM4HfjXbnRE4LlW6gvg== X-Received: by 2002:a25:df42:0:b0:e0b:3e24:88c3 with SMTP id 3f1490d57ef6-e0b545a5fadmr937537276.35.1722022628266; Fri, 26 Jul 2024 12:37:08 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0b2a70e96csm837885276.42.2024.07.26.12.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:07 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 29/46] btrfs: convert btrfs_cleanup_ordered_extents to use folios Date: Fri, 26 Jul 2024 15:36:16 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We walk through pages in this function and clear ordered, and the function for this uses folios. Update the function to use a folio for this whole operation. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a95bbe602a90..d1c81a368b52 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -399,7 +399,7 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode, unsigned long index = offset >> PAGE_SHIFT; unsigned long end_index = (offset + bytes - 1) >> PAGE_SHIFT; u64 page_start = 0, page_end = 0; - struct page *page; + struct folio *folio; if (locked_page) { page_start = page_offset(locked_page); @@ -421,9 +421,9 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode, index++; continue; } - page = find_get_page(inode->vfs_inode.i_mapping, index); + folio = __filemap_get_folio(inode->vfs_inode.i_mapping, index, 0, 0); index++; - if (!page) + if (IS_ERR(folio)) continue; /* @@ -431,9 +431,9 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode, * range, then btrfs_mark_ordered_io_finished() will handle * the ordered extent accounting for the range. */ - btrfs_folio_clamp_clear_ordered(inode->root->fs_info, - page_folio(page), offset, bytes); - put_page(page); + btrfs_folio_clamp_clear_ordered(inode->root->fs_info, folio, + offset, bytes); + folio_put(folio); } if (locked_page) { From patchwork Fri Jul 26 19:36:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743097 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.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 31EA614EC4E for ; Fri, 26 Jul 2024 19:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022631; cv=none; b=igFzVtGfvHChbx3wyLkI/USBLHKauwjhS3oquSvfIY0WEKrz0XnpbxF9Sqdzd0gQVP9BnkkSBkeMLy3gDQi0tsHN62LYzJi9CsRLKmfthO6eU4SxQ1eyd2QCc0/FbvIcnpb0FN+dURjm8XJ6EWl7sYJJrgbrH2dDL5C4oFpHUXQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022631; c=relaxed/simple; bh=CAf2UpMV19L4WUW48ckmb8R3dcNGjV128CKSGQiVUgA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z+rC8hRcT0jgEwjPDkUcsZV5el8OmCJJJ8Mksi9m5j9giU/qrgwfUO10wrGK8R1BcbdPpKlxuceLoyPnr1HEKO74lT0zwrxhYPuCApZ58MXymmLrHbX0Jx1L/ixo7dJXPCCtnd/BFBmUExMkVhqfOJJhHx2TMLxrJREeNN+2OXQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=3a6Ckckd; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="3a6Ckckd" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-67682149265so382017b3.2 for ; Fri, 26 Jul 2024 12:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022629; x=1722627429; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WSKpljHV3Uo0sCNLwHxpIQpbtwjDivLUc2p915iNNkg=; b=3a6CkckdWasLXIGlgIg1sGsckIFN7MpTGZ1xVbHmd6a43cSdKNRM8UEJLi9z8chbKu EXZmxiUqWL4NMsyYuc/lPHiYksdoV65+iS7LM5DTHdunx6bgZYXRxG/VDpq9At81M5Lw mMayKuI2xlhRK9aS5+gl68ltaFSEtJikCC0IgbQ8444wGMVk/xIGfTb3oZqqXtdevncl i1Jx7as0cczlqRP9IeaeYKf0Bgu9OOtGYafKnREO452d01YGNUgRgl4YivMmHil82rVu MOFTLuTb9ePx3gjrjix3tT1+wpx6aCeWcC1PhsaA8JLgsvpcl9OCoYXoAa+qBpFLWeBM Yb3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022629; x=1722627429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WSKpljHV3Uo0sCNLwHxpIQpbtwjDivLUc2p915iNNkg=; b=omy3cnKV8HKOZWBL/KqpksM6cSP4fS94IhZX60rnrhGpNBkljyX9jIBdBvleF6zZIs y5fRbYtEHk689mT8Sdx2krkGtBhx4JPhMRrLAZvTxakoHcgX/tJgi/qhbTWrjL1IWZaW Sj2sw5NQ/McQC1cFZlwjs5ByJxZ0jnwCwt3Lvt94sVzbBpBQudIWIKSPBZRJOI/g4QrR A8L4y4EcmO5KYLB5Oqy3lQcDVmVf+uoZgbwRNY9IUtc7qBzQNds3MyRlKau/AT9m6WrB PWnlWhCo8hiHU7VMvDCQ/wz7vraFKiiCuevolgo4J0tqRTcGUSSam3Yan6QMTkW5XYUa ldrA== X-Gm-Message-State: AOJu0YyjplMzb73PJlEujHK78dmfYzWV5iIphEgk6U1ulyx0obofY4qY Hj25cR/Cw3WKny8kUAnvD5nI0PxAIqaTmEnr40bx6VzO5OVHFFXMio+ON/Twy2rcken2HIkjfoT Z X-Google-Smtp-Source: AGHT+IHkmVuZg+ByiY2hLs18u2aeTH2PJOeAGGx1yz+QuVkBpH9lDW85K3jeLkHoQLw1sqOnzOdmcg== X-Received: by 2002:a0d:c983:0:b0:62f:945a:7bb1 with SMTP id 00721157ae682-67a0a323dc1mr8640837b3.42.1722022629202; Fri, 26 Jul 2024 12:37:09 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756795e61csm10033467b3.42.2024.07.26.12.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:08 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 30/46] btrfs: convert btrfs_cleanup_ordered_extents to take a folio Date: Fri, 26 Jul 2024 15:36:17 -0400 Message-ID: <6987e88d64a5755e57742d39dbf2b5b690363e48.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that btrfs_cleanup_ordered_extents is operating mostly with folios, update it to use a folio instead of a page, and the update the function and the callers as appropriate. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d1c81a368b52..76fa9b1e0f11 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -393,7 +393,7 @@ void btrfs_inode_unlock(struct btrfs_inode *inode, unsigned int ilock_flags) * extent (btrfs_finish_ordered_io()). */ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode, - struct page *locked_page, + struct folio *locked_folio, u64 offset, u64 bytes) { unsigned long index = offset >> PAGE_SHIFT; @@ -401,9 +401,9 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode, u64 page_start = 0, page_end = 0; struct folio *folio; - if (locked_page) { - page_start = page_offset(locked_page); - page_end = page_start + PAGE_SIZE - 1; + if (locked_folio) { + page_start = folio_pos(locked_folio); + page_end = page_start + folio_size(locked_folio) - 1; } while (index <= end_index) { @@ -417,7 +417,7 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode, * btrfs_mark_ordered_io_finished() would skip the accounting * for the page range, and the ordered extent will never finish. */ - if (locked_page && index == (page_start >> PAGE_SHIFT)) { + if (locked_folio && index == (page_start >> PAGE_SHIFT)) { index++; continue; } @@ -436,9 +436,9 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode, folio_put(folio); } - if (locked_page) { + if (locked_folio) { /* The locked page covers the full range, nothing needs to be done */ - if (bytes + offset <= page_start + PAGE_SIZE) + if (bytes + offset <= page_start + folio_size(locked_folio)) return; /* * In case this page belongs to the delalloc range being @@ -447,8 +447,9 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode, * run_delalloc_range */ if (page_start >= offset && page_end <= (offset + bytes - 1)) { - bytes = offset + bytes - page_offset(locked_page) - PAGE_SIZE; - offset = page_offset(locked_page) + PAGE_SIZE; + bytes = offset + bytes - folio_pos(locked_folio) - + folio_size(locked_folio); + offset = folio_pos(locked_folio) + folio_size(locked_folio); } } @@ -1138,7 +1139,8 @@ static void submit_uncompressed_range(struct btrfs_inode *inode, &wbc, false); wbc_detach_inode(&wbc); if (ret < 0) { - btrfs_cleanup_ordered_extents(inode, locked_page, start, end - start + 1); + btrfs_cleanup_ordered_extents(inode, page_folio(locked_page), + start, end - start + 1); if (locked_page) { const u64 page_start = page_offset(locked_page); @@ -2317,8 +2319,8 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page out: if (ret < 0) - btrfs_cleanup_ordered_extents(inode, locked_page, start, - end - start + 1); + btrfs_cleanup_ordered_extents(inode, page_folio(locked_page), + start, end - start + 1); return ret; } From patchwork Fri Jul 26 19:36:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743099 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 4C717143C7B for ; Fri, 26 Jul 2024 19:37:11 +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=1722022632; cv=none; b=bvDa+MkYftBJSO7feaKdv/CukGbKZU8XkB4TZf2+Yt/zX1ElbsRBruqqqgt/sST4tOk9jGE2fey19W0n2DfI4y+QW49TK+hkXTR9DgZLEET3Usk0KmL14IwKtAwfuA6V2DxRc2k5NBc6aIH1WqT0pbtjrwXazwqKsSfR2nN7SUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022632; c=relaxed/simple; bh=FH9PJwcRIRQEaTwtlF7DaFwjKmxj9BeI7Fhe/e5iFQk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z3vaUURLqrkqqeqWSFpwfrvCD4g2jJM2lMJnlWXfLIMPseLRnTmiUL5Y3pAtz7V14XuAsO/Wo35yZb71ietKvQn3d1XW4+GOBcMgDZlgwWaRk5qwrrBpZlBCibMC+804lKQhgzdj+sJ076jT7bm7FS0CLnoaCeokKX+pK/DNEmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=Bc4qF75F; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="Bc4qF75F" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-6687f2f0986so609297b3.0 for ; Fri, 26 Jul 2024 12:37:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022630; x=1722627430; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9JYKSZjjub4MjUvTL+RGon1mBcuNGAyS/ZL6rxZXNbA=; b=Bc4qF75FsxoY4PYgtwnD4N5MWlQfEUzB19uSlL9v7lJzQZrmjRxYPyTCcwvsRZLqlT zAkAB77OeOhy9dOJ7/JG66FTz3H7OU7kHBAcjCWVoTGRgtMDUWzvG577bI2g38Oa9Z1L NdCPa/4T1YDig2bVWaqcxS6NqVMprtzkwIU9xmGgXPurPMez3dzFWXNEHMWuMuDFPMiV fDFmg7vuIKWRngMUd6G5xJVq8jPjh0hve5DEpxFPF+d2TQ0otaW/yJgeAkhdhe0JeKiW m5m7508NkVCOQ0zvAZ9cCs2WkFT0ay3P45AQN0GCrbJ2ML5A1lwwEl9F0P4mJXvcR4XG a6Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022630; x=1722627430; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9JYKSZjjub4MjUvTL+RGon1mBcuNGAyS/ZL6rxZXNbA=; b=vkziMbKDSKmfhDKUHX8T4xNwYp6S43amunC/2TghUfb9mHcA7CfXAnhikoPXx9Cpwj Wp+RQ6mYijginNBOJzaZ+ZGqNnT/YcDwkL7mJqWkMC4aBO140ldfboxFk2NflZF6xG/N wPRmT1bUpme4WijA4ywLiJ1oSLNg0jsVAjqS5CsUNISXHcu2wB71iXAEe2k429L6sNap uNPEcT/DTssCgTCWUffpivbebSdrCmQ1XuI0fRnlV/fzkjTD4t/ZoIUTCK8ocaoewBlN 11jpw/HRBZGSOrmGK+y9W3othMCZisK0W+EPXRPnNSHV1LHhVlcmsCtLgDX9O/NVAtxG IPwA== X-Gm-Message-State: AOJu0Ywxy7qBYr2jB0VGFr0wsyejGWFJ/BLyaKjhtFWNwiTuC6GO/V5b +JQL4qrahkvBs1fTQjdhowf54RGCm67sUW3Fu+rHgK93VS/wTsvS+8FU23bVUdfSuBY3AfbUx65 G X-Google-Smtp-Source: AGHT+IEhhZGTcYx3aX7T5rtBEvVGtw0YLn5+MfZqceSWDfUELZ2pbvPH8m5czdj5fj+0zbCVxJb1+A== X-Received: by 2002:a0d:d101:0:b0:64b:a3f0:5eee with SMTP id 00721157ae682-67a071c27d3mr9099987b3.17.1722022630270; Fri, 26 Jul 2024 12:37:10 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67566dd8e4bsm10000497b3.19.2024.07.26.12.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:09 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 31/46] btrfs: convert run_delalloc_compressed to take a folio Date: Fri, 26 Jul 2024 15:36:18 -0400 Message-ID: <01064d0e836a8545787ffc747c650626f38ea258.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This just passes the page into the compressed machinery to keep track of the locked page. Update this to take a folio and convert it to a page where appropriate. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 76fa9b1e0f11..23ab3000c5fd 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1653,7 +1653,7 @@ static noinline void submit_compressed_extents(struct btrfs_work *work, bool do_ } static bool run_delalloc_compressed(struct btrfs_inode *inode, - struct page *locked_page, u64 start, + struct folio *locked_folio, u64 start, u64 end, struct writeback_control *wbc) { struct btrfs_fs_info *fs_info = inode->root->fs_info; @@ -1693,15 +1693,16 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode, INIT_LIST_HEAD(&async_chunk[i].extents); /* - * The locked_page comes all the way from writepage and its - * the original page we were actually given. As we spread + * The locked_folio comes all the way from writepage and its + * the original folio we were actually given. As we spread * this large delalloc region across multiple async_chunk - * structs, only the first struct needs a pointer to locked_page + * structs, only the first struct needs a pointer to + * locked_folio. * * This way we don't need racey decisions about who is supposed * to unlock it. */ - if (locked_page) { + if (locked_folio) { /* * Depending on the compressibility, the pages might or * might not go through async. We want all of them to @@ -1711,10 +1712,10 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode, * need full accuracy. Just account the whole thing * against the first page. */ - wbc_account_cgroup_owner(wbc, locked_page, + wbc_account_cgroup_owner(wbc, &locked_folio->page, cur_end - start); - async_chunk[i].locked_page = locked_page; - locked_page = NULL; + async_chunk[i].locked_page = &locked_folio->page; + locked_folio = NULL; } else { async_chunk[i].locked_page = NULL; } @@ -2307,7 +2308,8 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page if (btrfs_inode_can_compress(inode) && inode_need_compress(inode, start, end) && - run_delalloc_compressed(inode, locked_page, start, end, wbc)) + run_delalloc_compressed(inode, page_folio(locked_page), start, end, + wbc)) return 1; if (zoned) From patchwork Fri Jul 26 19:36:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743100 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 6A31B14F115 for ; Fri, 26 Jul 2024 19:37:12 +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=1722022633; cv=none; b=KbHnLzoMwHgxBFKjjU6lhlq8vdGrdehJl9UiHVsPJv2xCDsRJfPyj3RzThFYcJQHRPS/OIDPfwl6k57/3bv3AFfnpiu8PugFleV6j2C3p5ESlVEKOgFqhqGe2A+KWpVOXePjJmjUzvJaymhFJn/m3+lwluGOUq3B2xmSpQRajXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022633; c=relaxed/simple; bh=nsfM3zMcpVUyNL5Ean7WRsl0Oh1USVr/mqPHZrs9LfE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E7f0Vyx47mA5bmtyBz0vkE1WROdXM59T8ztp889HZHQhQMiFgu+dgaL6GrHkFrgDOPsWAFQ9af/NdLzKoLbnEVh1GYvrFz7cUdiIM5jDwdFzkIsOSQ0UZMXEuHeaLF42ZbgPzwMEGipFIQRjUdEWCzVm4zH5GJDiMzD7/Irl5Sw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=p9JclY1y; arc=none smtp.client-ip=209.85.219.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="p9JclY1y" Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-e08a538bf7bso27922276.1 for ; Fri, 26 Jul 2024 12:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022631; x=1722627431; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uNeFyrm8SB7ZMcTCebN8aon1cYbETgbo/mpbSpe5IDM=; b=p9JclY1yULlTorltrdXQwgHQ129EHEtJPPo4hs/QdkIHWhSNWsF8rvWJCEkvsslmI+ EVH5BKhJfeofTeGrN6xVQ/CZIXPpqUfBgbZgWLFv+SP/CHOM/3O0+S8wolGgymyKthkQ JgkFBqOWAXQSqSzCS/FYPBHmEmYvYJOfCyxlgxmnpkujM7DxJ+o9J5jVGsz2QXnDAxqX pnqp4NchITV1aVZ5CljQOvxAB8+IaWBPe1f28Pesr4MKcc9Mkei9ZrQo6hR1v4kGHvBv R1r5liKHOcLKbHW7IfjjiTecl6jkQljLvT+Z/25x6gbs09canlnqKJllxcn8iD4fGMqQ RO6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022631; x=1722627431; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uNeFyrm8SB7ZMcTCebN8aon1cYbETgbo/mpbSpe5IDM=; b=tNvAf7naS+2OKJrt7S9g1zsoNX8oXNchdFJtp1kPNbPUftHV3prJuWXZ55gFNUiZSk PhVnEHhHcQPLsXSLsAgklPzQoDkiKCfcY9jfQH0LGI2LtrOjdRcYgXMDn+nyRAewIwKp 5dMZYx72GYptfCUZb9wNhsaTxHi1rRYwsimtCOHDjnPVR9KErmqEkjviO5RwcDMjoyND w9xPTbmrMJ22GebK1P2DeYdKeY7VGUMA3XClxd4H05tdAvb+Uqe1rC0YKRAUaGt3sZsd RhTDGpGie3tNWx9m+VCDA6ClnbUd9BTlmfsMsr/ZGgiK8rggyqMBX9tfRtHl8bW7lKj5 IpNQ== X-Gm-Message-State: AOJu0YzL0RCyVln8nw7GkfXOZpxAjdkayllxqYxOkaemkMfzd4PuilHa HS54TyxI3j3MH228AQuzydcolz5DFygByd2gQBEd+7kmQVp7bJwpCasknT5jPkE3/YcvXSCSZ8C I X-Google-Smtp-Source: AGHT+IGdqGw9comAuy70AjVy8VcUDXnf3VQ+oqNmRyIdMGvk4ySrSxYgJ7VbXcSdGqIn7OGMVum75Q== X-Received: by 2002:a05:6902:140f:b0:e0b:28f5:3ff7 with SMTP id 3f1490d57ef6-e0b5552689dmr619482276.4.1722022631248; Fri, 26 Jul 2024 12:37:11 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0b2a940871sm879068276.59.2024.07.26.12.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:10 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 32/46] btrfs: convert btrfs_run_delalloc_range to take a folio Date: Fri, 26 Jul 2024 15:36:19 -0400 Message-ID: <4e67606e76ff4bdd037909ba18c994b94354ab83.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that every function that btrfs_run_delalloc_range calls takes a folio, update it to take a folio and update the callers. Signed-off-by: Josef Bacik --- fs/btrfs/btrfs_inode.h | 2 +- fs/btrfs/extent_io.c | 2 +- fs/btrfs/inode.c | 26 ++++++++++++-------------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 3056c8aed8ef..5599b458a9a9 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -596,7 +596,7 @@ int btrfs_prealloc_file_range_trans(struct inode *inode, struct btrfs_trans_handle *trans, int mode, u64 start, u64 num_bytes, u64 min_size, loff_t actual_len, u64 *alloc_hint); -int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page, +int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct folio *locked_folio, u64 start, u64 end, struct writeback_control *wbc); int btrfs_writepage_cow_fixup(struct page *page); int btrfs_encoded_io_compression_from_extent(struct btrfs_fs_info *fs_info, diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 1faadf903e00..2f46a85888b9 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1254,7 +1254,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, if (ret >= 0) { /* No errors hit so far, run the current delalloc range. */ - ret = btrfs_run_delalloc_range(inode, &folio->page, + ret = btrfs_run_delalloc_range(inode, folio, found_start, found_start + found_len - 1, wbc); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 23ab3000c5fd..a16b9aba7f96 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2287,42 +2287,40 @@ static bool should_nocow(struct btrfs_inode *inode, u64 start, u64 end) * Function to process delayed allocation (create CoW) for ranges which are * being touched for the first time. */ -int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page, +int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct folio *locked_folio, u64 start, u64 end, struct writeback_control *wbc) { const bool zoned = btrfs_is_zoned(inode->root->fs_info); int ret; /* - * The range must cover part of the @locked_page, or a return of 1 + * The range must cover part of the @locked_folio, or a return of 1 * can confuse the caller. */ - ASSERT(!(end <= page_offset(locked_page) || - start >= page_offset(locked_page) + PAGE_SIZE)); + ASSERT(!(end <= folio_pos(locked_folio) || + start >= folio_pos(locked_folio) + folio_size(locked_folio))); if (should_nocow(inode, start, end)) { - ret = run_delalloc_nocow(inode, page_folio(locked_page), start, - end); + ret = run_delalloc_nocow(inode, locked_folio, start, end); goto out; } if (btrfs_inode_can_compress(inode) && inode_need_compress(inode, start, end) && - run_delalloc_compressed(inode, page_folio(locked_page), start, end, - wbc)) + run_delalloc_compressed(inode, locked_folio, start, end, wbc)) return 1; if (zoned) - ret = run_delalloc_cow(inode, page_folio(locked_page), start, - end, wbc, true); + ret = run_delalloc_cow(inode, locked_folio, start, end, wbc, + true); else - ret = cow_file_range(inode, page_folio(locked_page), start, end, - NULL, false, false); + ret = cow_file_range(inode, locked_folio, start, end, NULL, + false, false); out: if (ret < 0) - btrfs_cleanup_ordered_extents(inode, page_folio(locked_page), - start, end - start + 1); + btrfs_cleanup_ordered_extents(inode, locked_folio, start, + end - start + 1); return ret; } From patchwork Fri Jul 26 19:36:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743101 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.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 627D91411C7 for ; Fri, 26 Jul 2024 19:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022634; cv=none; b=XqQce2VTAXQFe8YLgYyN/DE8mAAArVC0Alv41PZPQSXVH83wULEo84NbCvwa7eaQqppTwHdi4dvWBiKhVwvwUGcEN0Gkyv1lBofkRRnaTWzdi/KVfvGwL/cU25xP4GR1gASa4WHFdAG0XyJNeUqTo9I8YL/eWWVrEh+uqFs1MYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022634; c=relaxed/simple; bh=agAlbopw3nRwca0vCu1M+C9rFYflBTTLqwpHyyIqx9w=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mFqafyH6p1ZAj2tad1IYrayzPFNpdWuo2/JRdy6ZpqWhHI3IzRQjymAVLrf/cW4W49h01zmI5lhgwAZcLpLtzu0BNFzyZWhzSCCfaVrF53jY1t4rDVuiHpS0Cj/HF7V4WVmofEqFbnwAjcxGZpByvr0GkTPso/KBPsfhWeXiKvg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=eppE/qSc; arc=none smtp.client-ip=209.85.219.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="eppE/qSc" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e0875f1e9edso40018276.1 for ; Fri, 26 Jul 2024 12:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022632; x=1722627432; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=62w1ABzJsgX2xh/QeMOLQvJI5/rE2l7TUavNj7Crc2g=; b=eppE/qScgU+R1tW8W1NuQDfb+EZpS4au6F55EV0S+BQnHR//p55StRCnmSNcoJ2e1j 2LFawlpZdaZWpCxF7mMcBpZ13Zz5lymChEwDXbylIRhKyYMQwH4bHYcCFBvldOn+jd1j nunSnvy01XfAYwLFNv7HirG5eodFDyl/X+trhNaHhEV9zCInQKBKutDwu+I4FYkAFlrI 0QnDMFAR2sxOps6v0kBeS+vxY9THYh8TH/D4/uWwGTkaGDK5IW+wz8mpE8L8qrQ1Xp1+ +D/RYG5TE7Ilh6oZirdPPFJSQuiGPYVvvUWJ4GEn3bl3pxwXqeopjor0himF91QXcGR7 QHiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022632; x=1722627432; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=62w1ABzJsgX2xh/QeMOLQvJI5/rE2l7TUavNj7Crc2g=; b=RxFB/92w0XegoHnqtaxavg27FIHb0qMvvV/RsPJSRFbrKuczcvXCL/1ypIFaT5Fklb ZHzZCspnZCNkMGbtVDKItcDRyIJjMR89FpFm6KV2+UZixcmOqDBN8sy6Wu/ncEHjU+WF k62aWwEDSlvCZfhAhAY1iO4F+T8clZUkO+UnjfXxIHQ8s8mJYfFPk+Juylhb7tJZ+qvD FNN0kY3ybEtqYk1deqBpdG2wTT6/c1QKvM1tn130fPcTpywXhJNQB9fqOg+9hWGtNhNl 6lcZ93eLDeCDZLo/N8y1XftlVxyLAc2Cs3FFoHtVPU+AdtCKkIfm/KmFIa/6kp85rAUM I5WA== X-Gm-Message-State: AOJu0YyY4hnxRFoGMn48LwNAoONDVnhwFgKO6uz0arN75dw4GxvxJQza WPcfzP2sXh52qYewrnAWkhuCn1FHM5b3m4mZNASnoqqB3YfkYq8CNAh4ySs7Lk96QST21pihnUW 2 X-Google-Smtp-Source: AGHT+IGEbwn5Fo3oeQAyt3pWxzDKH9yeASjE+Np8Z04en932H4588TIOtm1O9aO/8/+kCxZW++PUTQ== X-Received: by 2002:a25:e0d7:0:b0:e0b:3a3a:8734 with SMTP id 3f1490d57ef6-e0b5465c93dmr749682276.56.1722022632327; Fri, 26 Jul 2024 12:37:12 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0b29f1b971sm846572276.7.2024.07.26.12.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:12 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 33/46] btrfs: convert async_chunk to hold a folio Date: Fri, 26 Jul 2024 15:36:20 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of passing in the page for ->locked_page, make it hold a locked_folio and then update the users of async_chunk to act accordingly. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a16b9aba7f96..fbb21deef54c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -762,7 +762,7 @@ struct async_extent { struct async_chunk { struct btrfs_inode *inode; - struct page *locked_page; + struct folio *locked_folio; u64 start; u64 end; blk_opf_t write_flags; @@ -1167,7 +1167,7 @@ static void submit_one_async_extent(struct async_chunk *async_chunk, struct btrfs_ordered_extent *ordered; struct btrfs_file_extent file_extent; struct btrfs_key ins; - struct page *locked_page = NULL; + struct folio *locked_folio = NULL; struct extent_state *cached = NULL; struct extent_map *em; int ret = 0; @@ -1178,19 +1178,20 @@ static void submit_one_async_extent(struct async_chunk *async_chunk, kthread_associate_blkcg(async_chunk->blkcg_css); /* - * If async_chunk->locked_page is in the async_extent range, we need to + * If async_chunk->locked_folio is in the async_extent range, we need to * handle it. */ - if (async_chunk->locked_page) { - u64 locked_page_start = page_offset(async_chunk->locked_page); - u64 locked_page_end = locked_page_start + PAGE_SIZE - 1; + if (async_chunk->locked_folio) { + u64 locked_folio_start = folio_pos(async_chunk->locked_folio); + u64 locked_folio_end = locked_folio_start + + folio_size(async_chunk->locked_folio) - 1; - if (!(start >= locked_page_end || end <= locked_page_start)) - locked_page = async_chunk->locked_page; + if (!(start >= locked_folio_end || end <= locked_folio_start)) + locked_folio = async_chunk->locked_folio; } if (async_extent->compress_type == BTRFS_COMPRESS_NONE) { - submit_uncompressed_range(inode, async_extent, locked_page); + submit_uncompressed_range(inode, async_extent, &locked_folio->page); goto done; } @@ -1205,7 +1206,8 @@ static void submit_one_async_extent(struct async_chunk *async_chunk, * non-contiguous space for the uncompressed size instead. So * fall back to uncompressed. */ - submit_uncompressed_range(inode, async_extent, locked_page); + submit_uncompressed_range(inode, async_extent, + &locked_folio->page); goto done; } @@ -1714,10 +1716,10 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode, */ wbc_account_cgroup_owner(wbc, &locked_folio->page, cur_end - start); - async_chunk[i].locked_page = &locked_folio->page; + async_chunk[i].locked_folio = locked_folio; locked_folio = NULL; } else { - async_chunk[i].locked_page = NULL; + async_chunk[i].locked_folio = NULL; } if (blkcg_css != blkcg_root_css) { From patchwork Fri Jul 26 19:36:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743102 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 7B24015099D for ; Fri, 26 Jul 2024 19:37:14 +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=1722022635; cv=none; b=WqdZ2eZAfkYbehKf5VlzznMiOJWnqkeE/hV3oZqBbFJaJ+byzmmtPS0jKdz2pgRxlBq2SDnbgsKFv2kF5RWzi/hgYyJ2kfSR3RY2nHFNYPYXV33Og/2vyeJYW8Ruf3JLN1l5d1w4jbUBeRxBcJs4sJmlcq7bprT9F0bkbqqXHo0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022635; c=relaxed/simple; bh=xZkxTBvrEGBvnKqxi15p94+Tq0G60Q85AQA3RDENQBg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aN0cSGrMobTyUY0zVTek2zjHFrtUlTnHWnI8B7OQG/onVQLLilbChVv3rNohg2P5fu0zTlTR5Xf7mdw2GNnV3rnaefG2PuSd80vAuz7dUu/4kyk941kBg6XM5CS1PMLtBnNAFlr6WJ/miSjorLVh2wpEGRZJqvwrpri+KqGe4Nw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=i1f2ij/M; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="i1f2ij/M" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-661369ff30aso253687b3.2 for ; Fri, 26 Jul 2024 12:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022633; x=1722627433; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=me0VKgAN2KFbNoR9iuS3kpxAOxLpUE7CuuHfYYTFvoE=; b=i1f2ij/MvRQveNPqfab37RcFrxwmF2Dng3kzRBoKEnLseQh8KMezqRv0Fx7S+E0m8L QkZoMpT0soNw6niRyJ9W26eat8JW18spwQw+X0KSwJKmsEiTN//9uoXDWlgTzbsWy9lp Hr6AyrBgrvOD5IarmE4Utv+jQWPuJJDLp9jxnXZ58zfb6z5PdUeJ9iHayXD8JsvVnh4M 2WbAq1OsnRKHe7U7rka6xH/OO+R+YoUH7T2+kWf/5iKbmsnDXxJayWy13dKf2Udn2OCX JN+pxpTykOYaodw/zoLGuqasnMe0d0toGcytCdBrJLRkM/6vy3C0I0FlGsN6TzUFn5kg pDHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022633; x=1722627433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=me0VKgAN2KFbNoR9iuS3kpxAOxLpUE7CuuHfYYTFvoE=; b=sYQnbPx98lpR8uI3hFiARnbQ3H0vv1WobU8dqSrT3izb+N8ejFjEvx/7MmNy9Kw1Qg 0Sh/Dbt3QiUuVj9yg51gZTTDpNmFlqpGM9rqj41NeBiSSNDSJWlax67bJ51DYt62FvWW vI9DZEUJ2hLzJhmudaJQ59eWP0nXJSw6JgkrKHohX733VGygAY6ffqWSIxv0ggMtr9sv pALbuIQlna4o4mh2Qpe2YH/ZLVh1cR9E6gW9RE7BzFyXZeEcBqTm1ZdwsQQsHObuOv9/ E9zIhxzQofeu92We94bHEwPHDGqLxH9/i3exzfXKCZt058mV9AXSYrjUk2BpLDDFzg0m pFdQ== X-Gm-Message-State: AOJu0Yy0Ph/tc9nss6qOHgsESZvneQ616/yjjkI2u3FtLUr7o8+Jc4Bo hPH2PqT2C4x4iM7uox+mtX3is2vX/wsFU3KVBt1kjMR8nMwDKir20kK78PjdVEFC67D2XXNPgty o X-Google-Smtp-Source: AGHT+IGRHzZH4ksuMdpWFonmucn25KjCH46B7I5KPbjyonWeRbAVYIPl6p7iRKNNAQjeKKWEVE4hLQ== X-Received: by 2002:a81:87c7:0:b0:62f:4149:7604 with SMTP id 00721157ae682-67a053e0700mr9699887b3.4.1722022633240; Fri, 26 Jul 2024 12:37:13 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756bab4cfbsm9949047b3.122.2024.07.26.12.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:12 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 34/46] btrfs: convert submit_uncompressed_range to take a folio Date: Fri, 26 Jul 2024 15:36:21 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This mostly uses folios already, update it to take a folio and update the rest of the function to use the folio instead of the page. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index fbb21deef54c..737af2d6bebe 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1122,7 +1122,7 @@ static void free_async_extent_pages(struct async_extent *async_extent) static void submit_uncompressed_range(struct btrfs_inode *inode, struct async_extent *async_extent, - struct page *locked_page) + struct folio *locked_folio) { u64 start = async_extent->start; u64 end = async_extent->start + async_extent->ram_size - 1; @@ -1135,23 +1135,22 @@ static void submit_uncompressed_range(struct btrfs_inode *inode, }; wbc_attach_fdatawrite_inode(&wbc, &inode->vfs_inode); - ret = run_delalloc_cow(inode, page_folio(locked_page), start, end, + ret = run_delalloc_cow(inode, locked_folio, start, end, &wbc, false); wbc_detach_inode(&wbc); if (ret < 0) { - btrfs_cleanup_ordered_extents(inode, page_folio(locked_page), + btrfs_cleanup_ordered_extents(inode, locked_folio, start, end - start + 1); - if (locked_page) { - const u64 page_start = page_offset(locked_page); + if (locked_folio) { + const u64 page_start = folio_pos(locked_folio); - set_page_writeback(locked_page); - end_page_writeback(locked_page); - btrfs_mark_ordered_io_finished(inode, - page_folio(locked_page), + folio_start_writeback(locked_folio); + folio_end_writeback(locked_folio); + btrfs_mark_ordered_io_finished(inode, locked_folio, page_start, PAGE_SIZE, !ret); - mapping_set_error(locked_page->mapping, ret); - unlock_page(locked_page); + mapping_set_error(locked_folio->mapping, ret); + folio_unlock(locked_folio); } } } @@ -1191,7 +1190,7 @@ static void submit_one_async_extent(struct async_chunk *async_chunk, } if (async_extent->compress_type == BTRFS_COMPRESS_NONE) { - submit_uncompressed_range(inode, async_extent, &locked_folio->page); + submit_uncompressed_range(inode, async_extent, locked_folio); goto done; } @@ -1206,8 +1205,7 @@ static void submit_one_async_extent(struct async_chunk *async_chunk, * non-contiguous space for the uncompressed size instead. So * fall back to uncompressed. */ - submit_uncompressed_range(inode, async_extent, - &locked_folio->page); + submit_uncompressed_range(inode, async_extent, locked_folio); goto done; } From patchwork Fri Jul 26 19:36:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743103 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 6A6B2152160 for ; Fri, 26 Jul 2024 19:37:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022636; cv=none; b=YQ4AVGwsKkS5FOUTMnDkxO8L/MSWGSTzY/3NDJg5Bw2entp76VILROar3UaJQuSdbmrM25LMu0eFA13oQW3NQKRbye4jI4bYsaOenVqCjYtY71Uw+m7QgMiM2THczTCo8ufdHCFlg0BfgdnZMlZYHq+vuHGU+RNpM1W0jIUsnNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022636; c=relaxed/simple; bh=WbKQNr3nFvtMUMDJ+qPYfoFfJeDxtvjxl32cHWMKx54=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h51ID6yI3yUzAhcaTpGWIMRbgI3Yj6OaW6wak+P10uapZvqqe9OsQ4CfdVPzwHBYwEx0Zstgemti0JEprDr4pDP041IsMmEeM6GIH09qpox8vZtc+/zn+F6siNmMBoQeRdsS1idulg4Hxjwrg6p/6R0ODTUz5I5vIYHLu+cTZNg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=P9vs0QUY; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="P9vs0QUY" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-65f8626780aso317817b3.3 for ; Fri, 26 Jul 2024 12:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022634; x=1722627434; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=TQJvLEfWkqq8rtFI9HcDlFrYqn6E4JTJ+NOi0KklxKc=; b=P9vs0QUY3Ncyc3z6vWrrhvVYenyCT6oT/bMgP4e8sWhnIhMlsC06/7yIXc2bdpodmH x4N1KPElh2ruOnz0EIOlYlWwbIWRlvoknbh4AGl5CNPznk1XqvMthWQ4uYUKehVNG2KY fVg7iKDyv1EcVm85GkBkYSHNKOjIvsfMyWzMT/ETvGSlAvPpZNbsOonAu9PDk79zg5lC oztdz4bFGwCRsPhAVoy8MeUY66NJ+CHZiVJa8A/BKDj1DCFFbknhkdilbIM0lw6MrHxF 5/uhP7C4Uww0unmMvCGgEXKVAl+Tolp2rlgxsc6f+57roM8Atwxb9Ro0lxDaE8jdbeJN uoYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022634; x=1722627434; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TQJvLEfWkqq8rtFI9HcDlFrYqn6E4JTJ+NOi0KklxKc=; b=BZfhQ//WlvfrqESrI6iobixWKHzngK8B4v9SOrPWMb6PAJNmmWJ+iSfZUvkRBGo37w PWJLHGQV2ezByusZwO57rOGok9XGxhctg2S/exXf//LUf4PX6NW4G0qNaD5s2QZdBcrq dKAJ/Fd6/BidNG0W7NfnAl3fIuralJYMBCncD60bL+h3AN5/TFtwE2VMv8dQdfWG7MVA h1133el5cLV7moNcNBzDDnam1J/I5P0hDXNYUU7dHGKd4I6XNnSSoMN17Fn9Mz/UtkFG FiCkomjLlnv3IIJhAiON8x7DtVRWDONzaKznkdJnfbzJ5NWf9lQ6PfigeHurWW4EIhHO GIbg== X-Gm-Message-State: AOJu0Yzb/iy5ksezY0zKe4Yd826o7vezWf9vEn/GzmcyDdaOLF3WoEOj LLmMcbd/PI3cVw5tkImd01+JGcRX/kK7sruZvG2o82Qh7h5N4C36pxhNf2wy9HhkruX9A8ZRPdj 0 X-Google-Smtp-Source: AGHT+IHQ/H+Ktou04IBt3iLugMSYtYrNYrAEiL4sw0HlcXsUk02gGk/DMpLfGIbAo++GujaM7BbMnQ== X-Received: by 2002:a81:bb45:0:b0:664:f825:93ca with SMTP id 00721157ae682-67a085165f9mr9645157b3.25.1722022634311; Fri, 26 Jul 2024 12:37:14 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756795e824sm9962377b3.37.2024.07.26.12.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:14 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 35/46] btrfs: convert btrfs_writepage_fixup_worker to use a folio Date: Fri, 26 Jul 2024 15:36:22 -0400 Message-ID: <8f66d16a4f3e23fdfe0aea25cc495c41cda1d4b6.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This function heavily messes with pages, instead update it to use a folio. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 54 +++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 737af2d6bebe..cd1b3e956d7f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2708,49 +2708,51 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) struct extent_state *cached_state = NULL; struct extent_changeset *data_reserved = NULL; struct page *page = fixup->page; + struct folio *folio = page_folio(page); struct btrfs_inode *inode = fixup->inode; struct btrfs_fs_info *fs_info = inode->root->fs_info; - u64 page_start = page_offset(page); - u64 page_end = page_offset(page) + PAGE_SIZE - 1; + u64 page_start = folio_pos(folio); + u64 page_end = folio_pos(folio) + folio_size(folio) - 1; int ret = 0; bool free_delalloc_space = true; /* * This is similar to page_mkwrite, we need to reserve the space before - * we take the page lock. + * we take the folio lock. */ ret = btrfs_delalloc_reserve_space(inode, &data_reserved, page_start, - PAGE_SIZE); + folio_size(folio)); again: - lock_page(page); + folio_lock(folio); /* - * Before we queued this fixup, we took a reference on the page. - * page->mapping may go NULL, but it shouldn't be moved to a different + * Before we queued this fixup, we took a reference on the folio. + * folio->mapping may go NULL, but it shouldn't be moved to a different * address space. */ - if (!page->mapping || !PageDirty(page) || !PageChecked(page)) { + if (!folio->mapping || !folio_test_dirty(folio) || + !folio_test_checked(folio)) { /* * Unfortunately this is a little tricky, either * - * 1) We got here and our page had already been dealt with and + * 1) We got here and our folio had already been dealt with and * we reserved our space, thus ret == 0, so we need to just * drop our space reservation and bail. This can happen the * first time we come into the fixup worker, or could happen * while waiting for the ordered extent. - * 2) Our page was already dealt with, but we happened to get an + * 2) Our folio was already dealt with, but we happened to get an * ENOSPC above from the btrfs_delalloc_reserve_space. In * this case we obviously don't have anything to release, but - * because the page was already dealt with we don't want to - * mark the page with an error, so make sure we're resetting + * because the folio was already dealt with we don't want to + * mark the folio with an error, so make sure we're resetting * ret to 0. This is why we have this check _before_ the ret * check, because we do not want to have a surprise ENOSPC - * when the page was already properly dealt with. + * when the folio was already properly dealt with. */ if (!ret) { - btrfs_delalloc_release_extents(inode, PAGE_SIZE); + btrfs_delalloc_release_extents(inode, folio_size(folio)); btrfs_delalloc_release_space(inode, data_reserved, - page_start, PAGE_SIZE, + page_start, folio_size(folio), true); } ret = 0; @@ -2758,7 +2760,7 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) } /* - * We can't mess with the page state unless it is locked, so now that + * We can't mess with the folio state unless it is locked, so now that * it is locked bail if we failed to make our space reservation. */ if (ret) @@ -2767,14 +2769,14 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) lock_extent(&inode->io_tree, page_start, page_end, &cached_state); /* already ordered? We're done */ - if (PageOrdered(page)) + if (folio_test_ordered(folio)) goto out_reserved; ordered = btrfs_lookup_ordered_range(inode, page_start, PAGE_SIZE); if (ordered) { unlock_extent(&inode->io_tree, page_start, page_end, &cached_state); - unlock_page(page); + folio_unlock(folio); btrfs_start_ordered_extent(ordered); btrfs_put_ordered_extent(ordered); goto again; @@ -2792,7 +2794,7 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) * * The page was dirty when we started, nothing should have cleaned it. */ - BUG_ON(!PageDirty(page)); + BUG_ON(!folio_test_dirty(folio)); free_delalloc_space = false; out_reserved: btrfs_delalloc_release_extents(inode, PAGE_SIZE); @@ -2806,14 +2808,14 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) * We hit ENOSPC or other errors. Update the mapping and page * to reflect the errors and clean the page. */ - mapping_set_error(page->mapping, ret); - btrfs_mark_ordered_io_finished(inode, page_folio(page), - page_start, PAGE_SIZE, !ret); - clear_page_dirty_for_io(page); + mapping_set_error(folio->mapping, ret); + btrfs_mark_ordered_io_finished(inode, folio, page_start, + folio_size(folio), !ret); + folio_clear_dirty_for_io(folio); } - btrfs_folio_clear_checked(fs_info, page_folio(page), page_start, PAGE_SIZE); - unlock_page(page); - put_page(page); + btrfs_folio_clear_checked(fs_info, folio, page_start, PAGE_SIZE); + folio_unlock(folio); + folio_put(folio); kfree(fixup); extent_changeset_free(data_reserved); /* From patchwork Fri Jul 26 19:36:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743104 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 6F048558B7 for ; Fri, 26 Jul 2024 19:37:16 +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=1722022637; cv=none; b=ACWCEW8M7Ovwgs8AIRCjHXr3p7qGvYqteo+VRXAygWFMAACf+Uq1Y0kR3zL4ClesLZF1GfBei8zxqaUHpI4nHOGO2uizB5g5mseLDI4fH2IXIUZxglPLTV7CpLA9/nytDlVnQFcVtj3B140LYhMImZ/UZpTah3Zmyly3rRfMQqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022637; c=relaxed/simple; bh=XqlwfmaVFe5J+bolmgGWz9FxsVuxHx0lGymGjzEj6Is=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e38Aje6JBT9LgmiMgxOgEgxWUJrlZ3Ap0ghdZJfXDL8Ooq4lRVsHXr7LgZTCvp4hRNWUAfo07YFs5RNZwmdmjYsWjxw49NRm1Fxx8jLLEl0bTtSAW8nR1pyi+axr5fXLCt7RzT62RIMsCVMW3rvuFwOCuzI1yhECJgOYJ7NTJ/o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=yO8/h7VA; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="yO8/h7VA" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-66c7aeac627so407717b3.1 for ; Fri, 26 Jul 2024 12:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022635; x=1722627435; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Eh9WsK9vEEAqGZ1xnhkwRSbLe82fmh0xBBwzgDkxLQI=; b=yO8/h7VA/nDSrrOKIvVgzbyiQonVIlCjCmUz/GxLhly1xfvpkVkGPzdC9W8devoa3b bcyJui1OPyGoAW+S07JiuFAtc6wleF2JcMl6n+Anc5B0fwSYGP6CpeXayXQ+tDUiDKqr yByJB4OHWvMoEPVvW7ObaI7b21cbvPytH2VryWCZlWHrvb96ASGINufmg3fvfpB7mRy+ 41NmEJPE8iP86KJULj3DE7oAPDKs2KOXDFurVd2ymlb9nWWWCCZfK0NtDX/+IpOR7uU5 db7ft2RnFdd7ZSpKWdhD4FOPqWIaAZJ4WapsE/IeV8vHSAALxoF15W8uHIfA4PBYcjwq 45AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022635; x=1722627435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Eh9WsK9vEEAqGZ1xnhkwRSbLe82fmh0xBBwzgDkxLQI=; b=m2LLnNZiEUoLAhRE+FRl9WlZKa7LH9Hat3rZ2eRsIHg4NO5c21MP3rcyfugdaypnFG 54ezccl3wo+SDbfu/wbFtexLxz7snp1b2EdCBKDWQbEvVmOA+66lWescjpuMxU892zkv BTkmuVpjyZLy3vStI/EUBva7TnXeGDQb89VOz18qMVr7ts/D3sgiTdzuewTwmdQ4Iqwm kyI99gAJBMbm8fLhWQqhLReWVTATuSmYIHj2cKWl9dged93Obox73Z0JyiGt9W7RulQq h0KaNrNwHEA/Um5oSIyABjcVPjXCMNLNEzJ1j8c71n+3UTinUPqYNR2qe996w+SqWO18 umyA== X-Gm-Message-State: AOJu0YxMxGosQFGGCIB/XK4SrfcO63ituEcRuFZZRQjM9sSfeRUVmOnd iriYZFF+wzxUjGsckejdqjlD/Ma8KTSzs0DzDcnUYUgRQmpYqWhZ1e+e2iVPIagn3im3m37IGHi H X-Google-Smtp-Source: AGHT+IEmRXQd8nq9bFqVylIvJXqMPRKM2whNd+AdA3JCY8ecz+zcKcKGQ3NSI0LYytj/ttm4kdu6Kw== X-Received: by 2002:a0d:ef01:0:b0:64b:7e17:b339 with SMTP id 00721157ae682-67a06edcc9amr9399367b3.15.1722022635459; Fri, 26 Jul 2024 12:37:15 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67566dd8feasm9936407b3.18.2024.07.26.12.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:15 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 36/46] btrfs: convert btrfs_writepage_cow_fixup to use folio Date: Fri, 26 Jul 2024 15:36:23 -0400 Message-ID: <731f88d939012cbde09a45ec30b0235134060336.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of a page, use a folio for btrfs_writepage_cow_fixup. We already have a folio at the only caller, and the fixup worker uses folios. Signed-off-by: Josef Bacik --- fs/btrfs/btrfs_inode.h | 2 +- fs/btrfs/extent_io.c | 2 +- fs/btrfs/inode.c | 31 ++++++++++++++++--------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 5599b458a9a9..fc60c0cde479 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -598,7 +598,7 @@ int btrfs_prealloc_file_range_trans(struct inode *inode, loff_t actual_len, u64 *alloc_hint); int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct folio *locked_folio, u64 start, u64 end, struct writeback_control *wbc); -int btrfs_writepage_cow_fixup(struct page *page); +int btrfs_writepage_cow_fixup(struct folio *folio); int btrfs_encoded_io_compression_from_extent(struct btrfs_fs_info *fs_info, int compress_type); int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode, diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 2f46a85888b9..ab5715de5f40 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1410,7 +1410,7 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, ASSERT(start >= folio_pos(folio) && start + len <= folio_pos(folio) + folio_size(folio)); - ret = btrfs_writepage_cow_fixup(&folio->page); + ret = btrfs_writepage_cow_fixup(folio); if (ret) { /* Fixup worker will requeue */ folio_redirty_for_writepage(bio_ctrl->wbc, folio); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index cd1b3e956d7f..9234ae84175a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2828,33 +2828,34 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) /* * There are a few paths in the higher layers of the kernel that directly - * set the page dirty bit without asking the filesystem if it is a + * set the folio dirty bit without asking the filesystem if it is a * good idea. This causes problems because we want to make sure COW * properly happens and the data=ordered rules are followed. * * In our case any range that doesn't have the ORDERED bit set * hasn't been properly setup for IO. We kick off an async process * to fix it up. The async helper will wait for ordered extents, set - * the delalloc bit and make it safe to write the page. + * the delalloc bit and make it safe to write the folio. */ -int btrfs_writepage_cow_fixup(struct page *page) +int btrfs_writepage_cow_fixup(struct folio *folio) { - struct inode *inode = page->mapping->host; + struct inode *inode = folio->mapping->host; struct btrfs_fs_info *fs_info = inode_to_fs_info(inode); struct btrfs_writepage_fixup *fixup; - /* This page has ordered extent covering it already */ - if (PageOrdered(page)) + /* This folio has ordered extent covering it already */ + if (folio_test_ordered(folio)) return 0; /* - * PageChecked is set below when we create a fixup worker for this page, - * don't try to create another one if we're already PageChecked() + * folio_checked is set below when we create a fixup worker for this + * folio, don't try to create another one if we're already + * folio_test_checked. * - * The extent_io writepage code will redirty the page if we send back + * The extent_io writepage code will redirty the foio if we send back * EAGAIN. */ - if (PageChecked(page)) + if (folio_test_checked(folio)) return -EAGAIN; fixup = kzalloc(sizeof(*fixup), GFP_NOFS); @@ -2864,14 +2865,14 @@ int btrfs_writepage_cow_fixup(struct page *page) /* * We are already holding a reference to this inode from * write_cache_pages. We need to hold it because the space reservation - * takes place outside of the page lock, and we can't trust - * page->mapping outside of the page lock. + * takes place outside of the folio lock, and we can't trust + * page->mapping outside of the folio lock. */ ihold(inode); - btrfs_folio_set_checked(fs_info, page_folio(page), page_offset(page), PAGE_SIZE); - get_page(page); + btrfs_folio_set_checked(fs_info, folio, folio_pos(folio), folio_size(folio)); + folio_get(folio); btrfs_init_work(&fixup->work, btrfs_writepage_fixup_worker, NULL); - fixup->page = page; + fixup->page = &folio->page; fixup->inode = BTRFS_I(inode); btrfs_queue_work(fs_info->fixup_workers, &fixup->work); From patchwork Fri Jul 26 19:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743105 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 7A96915350B for ; Fri, 26 Jul 2024 19:37:17 +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=1722022638; cv=none; b=pLjP/G8ubfA3io6lTKEjdhGNGQs5rifSMIfNgXSm5qJERnMQTC2W8ZbTaq8Bb2uWky3al7khlUSHv2KJHXZfnoZ+mkLxks+GtQ4EVW8m4mZEO7EXTkkATBeCdBhll3yq9X9PgG5grKvDYJh2MeLTgdVjrwX1uvkoVYIzJtwPYZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022638; c=relaxed/simple; bh=52yhmVRldo6fhrshj4UeNjlQ9T2sASylyx7e9qIOR0Q=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m5edXviHccDoZxDU7E52yz5cmIHVulcfkML0ko4oDFDyj3S8ohqaMPaxgPQSGINLKOltdBYGWX9XotwAJMMhwNqDsHCQtEnbYEo/sOHao3XKQl9OzGG5t9kpxIKn6mp7WYhDoTRQtz/l6yJ9xvsXwDQvbQ2LE5uzXmaEN/p8bQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=DvwPSxUG; arc=none smtp.client-ip=209.85.128.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="DvwPSxUG" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-664b4589b1aso304487b3.1 for ; Fri, 26 Jul 2024 12:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022636; x=1722627436; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fXkL2cHHcMIysYGbARqm/QB30uEPhELGuHXflxiPSGg=; b=DvwPSxUGCe/6svaaC9lwf9VT95oRmUMmGWeCQ1RfCTDt8fEGd6CNVsOuq4m8BhrtmG OPGbzCju1PBjYUlgAl8Gqp4wDuhPKjcuREf698NfRMsA2zhHUJJZkHOAUK4Kb+3GhjS0 WX2mFGCTEagzWHdFOtO2bBkzeEbPgQKLpyzHhcdsIfhvvkbs2XArk35U/cDCDKgkuDNz QJkxT8qV3RC1hWaeMnwUqb89ZBpNFLhaHGCBKBvb5v1WTE6g+FQoPnVKMhOk/vXgALP3 vRW5UE9uKy5XX9aWBxz+een5ATacrAQ4q28BuGOnbdyKA/yX0TQ45uxyVwYqpNj1ONOh ywWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022636; x=1722627436; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fXkL2cHHcMIysYGbARqm/QB30uEPhELGuHXflxiPSGg=; b=vESouWa51qQ8JJJlipWv/Nc3HcNqa/fS0jYdZCfbIF3GwhABDpPRylkyghBapBd4dp pjINgFawULpWMObFfXPsnhBEP0MWxDo5lfB/pWuslQsnLTpRTTA0fmBbsbsVoWpRhCtL 5u1zdpI5762zmeIDZwnRq7n22EPA9GRSYK0f2/rmkvRwz0YxyjcINitf0dCZVT0e3259 7IGDlBqSHFNFZyPMCJs9fyZymerzVfMusSTOPVu7Fn7aXpNA7lKOK5I3NJDPhNar+RqQ ML5TgyOY6XGnrioREq6g824KzAqN1dZYhoN5j4S3iNiA87rwYlbNRXjgiNH6/tRlvmRP /8zw== X-Gm-Message-State: AOJu0YzA6kZs7dniX3ca9uSrN5792QMo+x1bW9yLzMcSaPk4uW80LHhA 40SOzAgtcFDY0CahHc04GoNrJGf9MxLD7MwIzQLAHjthq40jnTMLXA1/pkqOWGlzVEpopAmzdiU P X-Google-Smtp-Source: AGHT+IFr/h4rnpeUNA5mbwDoIkZ8BTqwb33FWDL5SgmzFrC066nIu+zc/mYM49DSqQLr/kteMIgOng== X-Received: by 2002:a81:b54d:0:b0:62f:aa9a:93c6 with SMTP id 00721157ae682-67a29bfc4f8mr6250967b3.8.1722022636441; Fri, 26 Jul 2024 12:37:16 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67568113cf9sm9986107b3.70.2024.07.26.12.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:16 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 37/46] btrfs: convert btrfs_writepage_fixup to use a folio Date: Fri, 26 Jul 2024 15:36:24 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now the fixup creator and consumer use folios, change this to use a folio as well. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9234ae84175a..0667da7b1895 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2695,7 +2695,7 @@ int btrfs_set_extent_delalloc(struct btrfs_inode *inode, u64 start, u64 end, /* see btrfs_writepage_start_hook for details on why this is required */ struct btrfs_writepage_fixup { - struct page *page; + struct folio *folio; struct btrfs_inode *inode; struct btrfs_work work; }; @@ -2707,8 +2707,7 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work) struct btrfs_ordered_extent *ordered; struct extent_state *cached_state = NULL; struct extent_changeset *data_reserved = NULL; - struct page *page = fixup->page; - struct folio *folio = page_folio(page); + struct folio *folio = fixup->folio; struct btrfs_inode *inode = fixup->inode; struct btrfs_fs_info *fs_info = inode->root->fs_info; u64 page_start = folio_pos(folio); @@ -2872,7 +2871,7 @@ int btrfs_writepage_cow_fixup(struct folio *folio) btrfs_folio_set_checked(fs_info, folio, folio_pos(folio), folio_size(folio)); folio_get(folio); btrfs_init_work(&fixup->work, btrfs_writepage_fixup_worker, NULL); - fixup->page = &folio->page; + fixup->folio = folio; fixup->inode = BTRFS_I(inode); btrfs_queue_work(fs_info->fixup_workers, &fixup->work); From patchwork Fri Jul 26 19:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743106 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 69DD0153804 for ; Fri, 26 Jul 2024 19:37:18 +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=1722022639; cv=none; b=mbmuDx/rl6l3aTBnCyJb973zTYWMxeqels++OfmsvfZ3LN7usThf6Kivk9TOeIjeElZUAIC+6aIsyu4cZTDxYJgnByCDxYAB9ZopIlg5BTMJGQZNBcoP9KNOJvKy2XrHYr5oCw1KQ5Esdlbp8fUdJFfPvrSO81k7yLDQzKmW3sM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022639; c=relaxed/simple; bh=GucPEWsDIecsbuQ7OcD/S7ZoXmhr9y2dSl4EPPECVR8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RobRGmWq9kXQwYQkraLECVJIPyRZS5op/jNu1zg+ZtPs9yzI9jwgiNTpwygjQXDIaIyG96lrZErSR59anOgnGvoWHUyIvUb8QQQYaYwphovDQY8Y92QmzZmpljdNYQg3HAdETK3MX+64HR82y4euqcr7c6efPL9e5wxXjZsQJZk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=VOIvjoW8; arc=none smtp.client-ip=209.85.219.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="VOIvjoW8" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-dff1ccdc17bso46822276.0 for ; Fri, 26 Jul 2024 12:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022637; x=1722627437; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=nKd/OOuZGEJ2gmxvwAHNhhH1eEtc+48z6k83BbKebcQ=; b=VOIvjoW8jrd4otnzuo1a38Juq6FjTzbTacpJc8JkgILfSXWCgAapHM1BqcGJ6rycLe KsL4pCADeNJTj6e8niRkaOgNjYuAgT6J4ooR7+WB4SUSMHQQ1uayzt1F55D9ZhrzEvFv gNfltTdySMPUeB4LkyXdEU31jr3xUjErZWU7rCli/gaWMTrtaXrrlB0J5AoS2XJqc8e6 NTsQxMgKyGbk+rpOAM8JFeTOyW46XfNHtgYxDVik+udwBLvQrZgC1yeaynrPBJUgjEwj 76hNplxNUHhWWKzer2G7fnuE6IUnLjsFNuwR+uKwwP9Q/rAt7OX9AVdVLBnj5vVWuP0p WTjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022637; x=1722627437; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nKd/OOuZGEJ2gmxvwAHNhhH1eEtc+48z6k83BbKebcQ=; b=jU5KhjLIzE1LWxBmUDy59zJtxhM3f6JZdjRIay9zh0xI+0PDq5YaUIpQLR/P8XVQhK yd4BQoGt6kKhDzWTD7J7tfvMZZxbXvZNQHzQCFdwpyuU9f+H2ZVez2+Bg5BikfWvZAfI zp68Bzb5PUETeWxlXTB/qArNl/JtVTzaveHzvrKfIlbLmdzbf/N4pwLlq0cy+I6ER72n SHG8aB/AJ/R/3yyKDHc/yDnrmRPStZSAHRBan7zMgJy175e1pfjWKb89CjA7hxopJV9E GgguLJWaORwsscuXSOYOYA46h44zWhEWuQGE7rcJ/N2GjvE5LGWCrDFwlYDWf+3SlAnk yC3g== X-Gm-Message-State: AOJu0YzIUjNzhYevoaN/YrUzF4tooJXdIn2zpRQ77LHBW5t/j+VHonkH NDTjFhN+SLTE/ZQAHnQHn3DJ9wWBBTe/Uc7twm9UCuVy4q0p2zJa3ay33D6PkblKiuqhlzlhQgc k X-Google-Smtp-Source: AGHT+IGw9Z74f6+ywSDbO68enL1poiiVZME87EFyzneqAVkrcrlnbWye5215dpuFO2ylzh6RLgMbZA== X-Received: by 2002:a05:6902:188f:b0:e08:7600:4697 with SMTP id 3f1490d57ef6-e0b545c0434mr1076289276.46.1722022637380; Fri, 26 Jul 2024 12:37:17 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0b29f7ad81sm882558276.24.2024.07.26.12.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:17 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 38/46] btrfs: convert uncompress_inline to take a folio Date: Fri, 26 Jul 2024 15:36:25 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Update uncompress_inline to take a folio and update it's usage accordingly. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0667da7b1895..560575a5de03 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6706,7 +6706,7 @@ static int btrfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, } static noinline int uncompress_inline(struct btrfs_path *path, - struct page *page, + struct folio *folio, struct btrfs_file_extent_item *item) { int ret; @@ -6728,7 +6728,8 @@ static noinline int uncompress_inline(struct btrfs_path *path, read_extent_buffer(leaf, tmp, ptr, inline_size); max_size = min_t(unsigned long, PAGE_SIZE, max_size); - ret = btrfs_decompress(compress_type, tmp, page, 0, inline_size, max_size); + ret = btrfs_decompress(compress_type, tmp, &folio->page, 0, inline_size, + max_size); /* * decompression code contains a memset to fill in any space between the end @@ -6739,7 +6740,7 @@ static noinline int uncompress_inline(struct btrfs_path *path, */ if (max_size < PAGE_SIZE) - memzero_page(page, max_size, PAGE_SIZE - max_size); + folio_zero_range(folio, max_size, PAGE_SIZE - max_size); kfree(tmp); return ret; } @@ -6759,7 +6760,7 @@ static int read_inline_extent(struct btrfs_inode *inode, struct btrfs_path *path fi = btrfs_item_ptr(path->nodes[0], path->slots[0], struct btrfs_file_extent_item); if (btrfs_file_extent_compression(path->nodes[0], fi) != BTRFS_COMPRESS_NONE) - return uncompress_inline(path, page, fi); + return uncompress_inline(path, page_folio(page), fi); copy_size = min_t(u64, PAGE_SIZE, btrfs_file_extent_ram_bytes(path->nodes[0], fi)); From patchwork Fri Jul 26 19:36:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743107 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 6495D153838 for ; Fri, 26 Jul 2024 19:37:19 +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=1722022640; cv=none; b=u0ymVWyyA80XaWvl11z2bVcvWj75CJtoRVcV1kbCoQ+D/z82QDVUf/SgvdDxjR+5oWAZvcGHwW6e5Y4qNAkkCBR6oNFXOI1SD6OkpYfu+U7zNA82Qk8U6auTaupLvSu6xaeN/1gyUzKAlLVzWxadXlEbURvDzu+N5M2aQjSW+Xk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022640; c=relaxed/simple; bh=k84zTJHIwABe7nGZiPGCQt82uE4pZfm59ER8wNDn2hQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qiWyJCCvKDUg4FKXFAcH3r7Og2ksxWXQZwDrgNTQSV6vkqKRgRWbk/udBmDr2uRiXn3K/q+LR5nXggEn3GeSR/2wnl74sq/v+Q4fcrg/2q+ttlzZDI2ScYGeP3+Bsi2KjjmAlsAXGlyUhOCKS61V4H6BMOPQCZot6pxHlipsfec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=SHXgqMwC; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="SHXgqMwC" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-65cd720cee2so436157b3.1 for ; Fri, 26 Jul 2024 12:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022638; x=1722627438; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=acbllnNOdxbMXw+1G8ypfc7FDsBR+vgEoqqabjqdQ5M=; b=SHXgqMwC5SByVxLVtUci2vAjrvreApnLLMzpbh6DDLv2we3v7ywTDJOBCSKtZS+Nn1 YEzOTOmGTFxjOE/lTjdH5N5ZCb5npDfzFo+sAiLjA9ldsERzKoEqrqH/cEfmSseB/l4A eUUM2az2HR3xbzykrQeRUGdIW92ZrFXNjGMRPsjetCegdm6FqFr+apjK4hoHF00z01Mn HvPYOs82LeRdNd+BcCwe8qPtZUEmg/xZX8qCVnh5Lb6UEayTHwVtFz1F04b80noTO9gV G+GamybeJBS1n4aJO3jK5qzoy7V6L+zZyMYf2H6dcprlTPzJP+eJec16TOFhk+FNbVC4 H9jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022638; x=1722627438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=acbllnNOdxbMXw+1G8ypfc7FDsBR+vgEoqqabjqdQ5M=; b=R/4g7uYleIwo6FNUx9ECdezzxQJ8VrKQwRbmWL7ferx3ddxbKqArqANY/wmWGlcyAn FQpjhzBs3rvvEFR4GX+VJwRer0h5zJh0SQxnMS087h3h17ukIhXQBwpCP74OiOEdq7yL LCwX1VUmsZ/sfhOQ0Pai43RZvMOcWIxAjLQAK4IAeulc/s9FxtDdh07ObfpHfb+nI8C5 S0UzSQgkqVqfHNneyBDNHa/TTX14uQS9CK+qxg3TIdvsiy7DEdNv4hlJZmdzwi8Tgo4q 1QNty/MXIKn58ZGW1Ctv8ljBSIsQuYRhMmr8ThwpJtCOVlFFpK3Ta2Ka4Wn862ggPNFB lkIw== X-Gm-Message-State: AOJu0Yw9tkJGnrIm45AqHsIaZgQpsS8P8pvefvhYcaDUErMhWgXOJNdd qdXANJjZXdIXOIVK1Lx+V0UUA+OCF/z8M42777I/t90sUgJ/bu+AxM9tBXbhbuXPKtB8Qo/S8+p 8 X-Google-Smtp-Source: AGHT+IHkb9Ad/985KaAuBD3jBj3QoHJCDBKR3ZHrFGZfby/sjzZ//85/WBZl0utt72OGgdxbz+v2pQ== X-Received: by 2002:a0d:f386:0:b0:61b:df5:7876 with SMTP id 00721157ae682-67a05c8bb3bmr10149637b3.6.1722022638296; Fri, 26 Jul 2024 12:37:18 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756c44ded1sm9814537b3.145.2024.07.26.12.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:17 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 39/46] btrfs: convert read_inline_extent to use a folio Date: Fri, 26 Jul 2024 15:36:26 -0400 Message-ID: <4c5e26539f6f1d4f60ced23deb6f8818556de15e.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of using a page, use a folio instead, take a folio as an argument, and update the callers appropriately. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 560575a5de03..45835074aa6f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6746,30 +6746,30 @@ static noinline int uncompress_inline(struct btrfs_path *path, } static int read_inline_extent(struct btrfs_inode *inode, struct btrfs_path *path, - struct page *page) + struct folio *folio) { struct btrfs_file_extent_item *fi; void *kaddr; size_t copy_size; - if (!page || PageUptodate(page)) + if (!folio || folio_test_uptodate(folio)) return 0; - ASSERT(page_offset(page) == 0); + ASSERT(folio_pos(folio) == 0); fi = btrfs_item_ptr(path->nodes[0], path->slots[0], struct btrfs_file_extent_item); if (btrfs_file_extent_compression(path->nodes[0], fi) != BTRFS_COMPRESS_NONE) - return uncompress_inline(path, page_folio(page), fi); + return uncompress_inline(path, folio, fi); copy_size = min_t(u64, PAGE_SIZE, btrfs_file_extent_ram_bytes(path->nodes[0], fi)); - kaddr = kmap_local_page(page); + kaddr = kmap_local_folio(folio, 0); read_extent_buffer(path->nodes[0], kaddr, btrfs_file_extent_inline_start(fi), copy_size); kunmap_local(kaddr); if (copy_size < PAGE_SIZE) - memzero_page(page, copy_size, PAGE_SIZE - copy_size); + folio_zero_range(folio, copy_size, PAGE_SIZE - copy_size); return 0; } @@ -6944,7 +6944,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode, ASSERT(em->disk_bytenr == EXTENT_MAP_INLINE); ASSERT(em->len == fs_info->sectorsize); - ret = read_inline_extent(inode, path, page); + ret = read_inline_extent(inode, path, page_folio(page)); if (ret < 0) goto out; goto insert; From patchwork Fri Jul 26 19:36:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743109 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 915AE154BE0 for ; Fri, 26 Jul 2024 19:37:20 +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=1722022643; cv=none; b=WGfjW8gqFEkKB03XwKaW67FR925s82xfwaZsnwDwn0iH8ou1F5OpPUIUX4fI186qtwFuBKEl21sffscgipR9Jx7XurOGllw84Uv9jWiT/HvHnuwB6UJ2msSW4XVxOQKtbPyyLUCcTOku5snqULgq5655pr52n2JSuzqpDC++KPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022643; c=relaxed/simple; bh=pBmXwUgUff5UyMdThOEHcy7C6G9PZ2f4xSaXGNvjykA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sXGJHAXhF7ww+Oq07LkiPFghqj+Eg0nkyP3Fg1LHG74Le/7yf1ut+YeKB2oTokdoYZk8QCzWLAD7wzAvroM3cVPPMrpVouKvwqdR83TQ6bb9R98VI8GQgky2UxTtIIF5R0DZQRXTI12B7A37UrP3kCXYHDz28Su/zJaRg1JMXcI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=xTopWa+T; arc=none smtp.client-ip=209.85.219.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="xTopWa+T" Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e0875778facso30714276.3 for ; Fri, 26 Jul 2024 12:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022639; x=1722627439; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+d0/9lKjMdP113nceu4AM5nk6zUI0PzpLneOMwa1dqI=; b=xTopWa+TUa92TlIcyDrVFaWhZGxPqY7hS171xuG7+xmCWmeddA8s5v/bOj1HeVK6fz 68u7K0L3En+xe1bjkVPkGeYPKsBCNl9yaAkWdIapqUXFmYTIhZVPoqQBo5qNEpzp/6XZ EPRPvcvL+lDBbdriZufnSkE7fhML+SM6NnvvLEWboLzoJr74S4xDCBKdtXjuymLQVDfa zYCC0o+X7Nd7KFq6jtHCs71g+WZtVnUpGXb0Jcw/AxyzdKI2PU+2GLwZVqYbwb/8hpWs FXYLatxIKTzgQ5GjDafWvdN5nh64MJbqphI4GXrC3Tyfgxf51ACjtVCYj581nWpIUMaw ntvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022639; x=1722627439; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+d0/9lKjMdP113nceu4AM5nk6zUI0PzpLneOMwa1dqI=; b=e2ThY3ucBBmhN60qA3iPGMUXbAEfDnaUCH7e/5Cu5RbTFCMxSYInjeTN5l9SDkE+fr AEHibWUdrNOtn6cbk2mpdVZo9bca1hJW+LfKe+bPoOdUum/v11QT7sARoAT1JltZv9y9 KM2PKpcQ7dBVUbxxjOFbEd9qKLn8ClfAfv5gTdSr87V60w0lSgF1J0t69g53MfTt5aS1 1RP7CbuSto+r+DSYWFohdhp/yD4x5htmupx9axXFVd3PXgbJYtjrxH1X0OynUrh4j6YG p2zw3ZggnuP5y+ukduDEFZzkuQ2jkj7bf5k1vNmIt7xS8yVH1u12/y1ROq9QCPacXYDP ZvYA== X-Gm-Message-State: AOJu0YzoaeVuaqVpa5yIWJsB1MVOHn29+WSetAQ1YgVlgDKwgh2qWHsc VL0il6IMjEKWcpmsSTDMZHcI4r/hJP0tk8WMgSeVlqdv+K/Ube1Iqdgtuwxf+ZqjZe/8An2K/bn r X-Google-Smtp-Source: AGHT+IGy5pa3wanHI3NwJW8Gj+9IDiHZlGK/ANeIL0pRpvPyfFDFW5qDKA5XW8XPEJNMDN1sAxKD3g== X-Received: by 2002:a05:6902:2510:b0:e0b:2fd0:6d34 with SMTP id 3f1490d57ef6-e0b543f752amr938263276.6.1722022639529; Fri, 26 Jul 2024 12:37:19 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0b29f7a6a2sm847034276.23.2024.07.26.12.37.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:19 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 40/46] btrfs: convert btrfs_get_extent to take a folio Date: Fri, 26 Jul 2024 15:36:27 -0400 Message-ID: <1e43ac3826c7a24e8b73d7b33932e80f2fb878df.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We only pass this into read_inline_extent, change it to take a folio and update the callers. Signed-off-by: Josef Bacik --- fs/btrfs/btrfs_inode.h | 2 +- fs/btrfs/extent_io.c | 2 +- fs/btrfs/inode.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index fc60c0cde479..2d7f8da54d8a 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -578,7 +578,7 @@ struct inode *btrfs_iget_path(u64 ino, struct btrfs_root *root, struct btrfs_path *path); struct inode *btrfs_iget(u64 ino, struct btrfs_root *root); struct extent_map *btrfs_get_extent(struct btrfs_inode *inode, - struct page *page, u64 start, u64 len); + struct folio *folio, u64 start, u64 len); int btrfs_update_inode(struct btrfs_trans_handle *trans, struct btrfs_inode *inode); int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans, diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index ab5715de5f40..2a80dfbc8248 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -987,7 +987,7 @@ static struct extent_map *__get_extent_map(struct inode *inode, struct page *pag *em_cached = NULL; } - em = btrfs_get_extent(BTRFS_I(inode), page, start, len); + em = btrfs_get_extent(BTRFS_I(inode), page_folio(page), start, len); if (!IS_ERR(em)) { BUG_ON(*em_cached); refcount_inc(&em->refs); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 45835074aa6f..0cdb0b86e670 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6791,7 +6791,7 @@ static int read_inline_extent(struct btrfs_inode *inode, struct btrfs_path *path * Return: ERR_PTR on error, non-NULL extent_map on success. */ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode, - struct page *page, u64 start, u64 len) + struct folio *folio, u64 start, u64 len) { struct btrfs_fs_info *fs_info = inode->root->fs_info; int ret = 0; @@ -6814,7 +6814,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode, if (em) { if (em->start > start || em->start + em->len <= start) free_extent_map(em); - else if (em->disk_bytenr == EXTENT_MAP_INLINE && page) + else if (em->disk_bytenr == EXTENT_MAP_INLINE && folio) free_extent_map(em); else goto out; @@ -6944,7 +6944,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode, ASSERT(em->disk_bytenr == EXTENT_MAP_INLINE); ASSERT(em->len == fs_info->sectorsize); - ret = read_inline_extent(inode, path, page_folio(page)); + ret = read_inline_extent(inode, path, folio); if (ret < 0) goto out; goto insert; From patchwork Fri Jul 26 19:36:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743108 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 97804154456 for ; Fri, 26 Jul 2024 19:37:21 +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=1722022642; cv=none; b=t1P5kcA6YBce3XniSXriLEWxun/RkOEwVNCEA5lrrmZuhmGnseioPGV5s7EJhYLGTSeLHW2iirU064pbSazvK6C6ZGvUhD9oDY36QrE8dsEzoWJ41r7adfmdJlXtwyYKGGXn8YRxv9hMEBjBBWQ1Lbk1FbRLIGrbgFVqQXVAQhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022642; c=relaxed/simple; bh=PLJ29NEO52clYYfJGF9MwzhpdA0r4y0SLpuTLapXZzY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r9PKglynVK8xQ+QaUHbT7ITW330Z7/FHdwWsES7IgP0LV/bwdGWgIfD3kD/kZcrc4Ec9nO1gG+fX+LflwZVh7yt4Y+d1ayog82J3BM3VVFrqhXGzOLL7GhGP3rRtM+ra5DgeJ0HtYOlU2Qghgghg5QCyvKcDLASW8hxYsU8Lvz0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=Z8i5kDqX; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="Z8i5kDqX" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-65f8626780aso318567b3.3 for ; Fri, 26 Jul 2024 12:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022640; x=1722627440; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=QPUcVhMZZ/L8ca7G8wdv+jxTBowNruFOYlWCJrDk1kw=; b=Z8i5kDqXL/ySl1cibB8HCHrtHrq1RNe5yfBWKIX56GFcOKeLt2Cq4wqQAxgW6/9xuc G8ATKSjkxcnnx0XOuFJrLePTZEpzsvvIY/eqHxZstmkf/ZPVbIDQD9mc5qlciour0J3b q1ufHAuBKpkkSAfeKnf05OZSWLlBSrBVF/JJAzlQhjrqYzJy8VNyR+NO5vOLH/6jhN1b 0eY6V6AbThqQA1oTuQAAYJ+VpVdHDsrrkMdFnSQ8aVmSB8FuIHWCzj4gHDdg5hwg8Ydy WHEP4AOSwQhJVcQv7ukctxZ95r2wqKK/1BGuYTNgKGCS+9IiVY8GEq/5bqJOR+xlBM6K 4VmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022640; x=1722627440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QPUcVhMZZ/L8ca7G8wdv+jxTBowNruFOYlWCJrDk1kw=; b=AI8qmLF4yOhQjyEUPjEGPp+cQfrqOT0TOfMpuBCFDFExTF48N1K08wCrlnF/t4SltP cY3DEXWvnEcFg70M2h+J/+rntLcGFjh6x+ySUqm11wZrqk9CLbSt/ts/uEOFgEdTMD+2 WnP8C7KLXgRE3X4j4NZmeCM97Sc4j4BHoHlSFn4Hch/OYIS6Sy7XkIMepe+XbKUXtrJL b11ucp8XluEuQBbFJoN7IX+/+PDUG/uq6Ti5GnDyWMvheXWzomBG+p1xp3IK914No1uU 0PVTiQLJL5U4TKINQCQh2qwvslWSWpOWyWIiTcf2nnBKleAUL0mpcJ6n4qBmW67URJ4u gszQ== X-Gm-Message-State: AOJu0YyOP5BttmPElmk64HQPfmXwYHiRxXpZY2n6QocfnQZvyIG46gf5 RYfAkzSghw4dEuVxLIz7Esvb3jaDH41FBZc/QUPjdTTrKFzgZbUsKkCF6HxHaRxSG7/KWK8LQWy W X-Google-Smtp-Source: AGHT+IHIyGMP/plNLHjncgsSyWNzJtkEGgRIfJN8bgN8roM5nwJJe6mTqJwZ8mNKnEAX+yj9nKELMg== X-Received: by 2002:a81:a24e:0:b0:64a:d5fd:f19f with SMTP id 00721157ae682-67a072baa09mr8264117b3.18.1722022640583; Fri, 26 Jul 2024 12:37:20 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756c44c806sm9903617b3.136.2024.07.26.12.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:20 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 41/46] btrfs: convert __get_extent_map to take a folio Date: Fri, 26 Jul 2024 15:36:28 -0400 Message-ID: <2564fcf5127417ceb8b441e97da6cfe2cf75783e.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that btrfs_get_extent takes a folio, update __get_extent_map to take a folio as well. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 2a80dfbc8248..4e9f0baba2ca 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -968,8 +968,9 @@ void clear_page_extent_mapped(struct page *page) folio_detach_private(folio); } -static struct extent_map *__get_extent_map(struct inode *inode, struct page *page, - u64 start, u64 len, struct extent_map **em_cached) +static struct extent_map *__get_extent_map(struct inode *inode, + struct folio *folio, u64 start, + u64 len, struct extent_map **em_cached) { struct extent_map *em; @@ -987,7 +988,7 @@ static struct extent_map *__get_extent_map(struct inode *inode, struct page *pag *em_cached = NULL; } - em = btrfs_get_extent(BTRFS_I(inode), page_folio(page), start, len); + em = btrfs_get_extent(BTRFS_I(inode), folio, start, len); if (!IS_ERR(em)) { BUG_ON(*em_cached); refcount_inc(&em->refs); @@ -1050,8 +1051,8 @@ static int btrfs_do_readpage(struct folio *folio, struct extent_map **em_cached, end_folio_read(folio, true, cur, iosize); break; } - em = __get_extent_map(inode, folio_page(folio, 0), cur, - end - cur + 1, em_cached); + em = __get_extent_map(inode, folio, cur, end - cur + 1, + em_cached); if (IS_ERR(em)) { unlock_extent(tree, cur, end, NULL); end_folio_read(folio, false, cur, end + 1 - cur); From patchwork Fri Jul 26 19:36:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743110 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 C150A56B7C for ; Fri, 26 Jul 2024 19:37:22 +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=1722022644; cv=none; b=HIFRmlQsnmtvfO1j/FcuUOA5vkC8a6MYMpHwEGe0meES1m0DTG7QsqAeoS8P+X9EV9g2gAhwrX0UxmLrxMkxEw8fqba1SozIXJGYRkuFjY7VNzuQigQVfW/1ZcmS4xQdP7zaz94TPJzR7PB7VQ2ttpgHIM0DAw16jNwn8PLtCm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022644; c=relaxed/simple; bh=G4e4+w1d4Vq4YkL1BXTX3xBAwWPIZH0081iZauWDDzA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KufVe2Lcroo0ilg24R/Q54NELVplUAcLpy5bC0DN8ABYpUjryNE2fjnsCPHprisWI7FfhGkVBfpBrSVg7c5jn9pzyOfII6q4Nv1z+YQepQuIgl5uk2zWH+U4mgI3qpdO0N3IYL3agf4iuR4v8vcQCkNVTiCDDehtbjlvp0N/9gc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=OKAfW3gY; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="OKAfW3gY" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-66526e430e0so378027b3.2 for ; Fri, 26 Jul 2024 12:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022642; x=1722627442; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GWxUzphjlU3Edps+E87zIu344ovkxgwglVIJpfgxmYk=; b=OKAfW3gY112V9cfBkOINLnfYlFqERTeXeo3A7Fj05StzKjPT9YmIuykQFo2gaDXKhN /vJ2y+Q3fJRBfnW5dbCdTRRrOsbVMdoc20gtQPJMDVFnvNPH6sLGmljrYe3OcWygh+tE /LVwdme5fxh03ZQaAeyfuJqT6OJikLHLbSOokzQcosIxj1I+hNYQtsPTDhH7z32oma7w onmaux6VvJnQ8vEbo7fmTgDDdjVPHI9YrD335tghXMtCj8tZj4ikf3h31B5tYzaA82wL Dgb6Gwl+qCdOpcjpoTWvI0P/oz1f5EM8EZNK8ALdgIqZiPtUdK9Xu/4JEUdRnCVLFZVa knpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022642; x=1722627442; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GWxUzphjlU3Edps+E87zIu344ovkxgwglVIJpfgxmYk=; b=KyZjvnzN5dHfFBgYxSUeqcNd6IviJUNxsl2M8ISwKc+nJPDMVYjWwXIVYVaOxkcdyn bDTfws+Wt574Q3JoSMml+XPyuKvPUhsnC7p8b+OR1FUJpeQmTv103yy+hlekqVCOjJ8R g5Wt4a24ayleMjf4tWN8EJBGRFn3jG10hQHbvjj8dYVwZJ8iKIRHGw/ecKMoUC2jO9G5 YB4Ik4mUCguk8anSlrIBnlPcTd3RXo3HqCT7f18eiunUmOd11nvYIaIAcTKGwCEfIvDx TKq0MT/JsWhFIeycRvH7mXAsxtsWbTjgbUXxysa3XTfzeS1pLb/k5jxj/sSciBBeYi19 IggQ== X-Gm-Message-State: AOJu0YyW3jcX3KJWzSZducX71v6peH3fNDw6TdqYJgn+6UcX3gtu+jP7 Z8QrpiAu0SxPO1ZoE2SmN5by40k1jt4b32Rq6x3+E2mc9e60mhDpjc6PvBdIvfv7qGR/phy/ve1 J X-Google-Smtp-Source: AGHT+IFizDZEK9aeoHwfmLIheXo5zl3weiKF7wAt/rR+fHNB3jsyEfMbfBwJwngWGgsP5IB6RYHWxg== X-Received: by 2002:a81:ab53:0:b0:648:2c60:fdee with SMTP id 00721157ae682-67a0a1376demr9257687b3.38.1722022641774; Fri, 26 Jul 2024 12:37:21 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67561916209sm10108187b3.0.2024.07.26.12.37.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:21 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 42/46] btrfs: convert find_next_dirty_byte to take a folio Date: Fri, 26 Jul 2024 15:36:29 -0400 Message-ID: <68aebabe701ae3b96a2804104da6edb9817dce68.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We already use a folio some in this function, replace all page usage with the folio and update the function to take the folio as an argument. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 4e9f0baba2ca..040c92541bc9 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1348,9 +1348,8 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode, * If no dirty range is found, @start will be page_offset(page) + PAGE_SIZE. */ static void find_next_dirty_byte(const struct btrfs_fs_info *fs_info, - struct page *page, u64 *start, u64 *end) + struct folio *folio, u64 *start, u64 *end) { - struct folio *folio = page_folio(page); struct btrfs_subpage *subpage = folio_get_private(folio); struct btrfs_subpage_info *spi = fs_info->subpage_info; u64 orig_start = *start; @@ -1363,14 +1362,15 @@ static void find_next_dirty_byte(const struct btrfs_fs_info *fs_info, * For regular sector size == page size case, since one page only * contains one sector, we return the page offset directly. */ - if (!btrfs_is_subpage(fs_info, page->mapping)) { - *start = page_offset(page); - *end = page_offset(page) + PAGE_SIZE; + if (!btrfs_is_subpage(fs_info, folio->mapping)) { + *start = folio_pos(folio); + *end = folio_pos(folio) + folio_size(folio); return; } range_start_bit = spi->dirty_offset + - (offset_in_page(orig_start) >> fs_info->sectorsize_bits); + (offset_in_folio(folio, orig_start) >> + fs_info->sectorsize_bits); /* We should have the page locked, but just in case */ spin_lock_irqsave(&subpage->lock, flags); @@ -1381,8 +1381,8 @@ static void find_next_dirty_byte(const struct btrfs_fs_info *fs_info, range_start_bit -= spi->dirty_offset; range_end_bit -= spi->dirty_offset; - *start = page_offset(page) + range_start_bit * fs_info->sectorsize; - *end = page_offset(page) + range_end_bit * fs_info->sectorsize; + *start = folio_pos(folio) + range_start_bit * fs_info->sectorsize; + *end = folio_pos(folio) + range_end_bit * fs_info->sectorsize; } /* @@ -1443,7 +1443,7 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, break; } - find_next_dirty_byte(fs_info, &folio->page, &dirty_range_start, + find_next_dirty_byte(fs_info, folio, &dirty_range_start, &dirty_range_end); if (cur < dirty_range_start) { cur = dirty_range_start; From patchwork Fri Jul 26 19:36:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743111 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 CC768154BEB for ; Fri, 26 Jul 2024 19:37:23 +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=1722022645; cv=none; b=kPx6rXAatAngd17SY9vW+yKR/VihYXD6J93z3WqY3bClVPE9ZJth0WC6RvbdWisVJWwp4xOSm70HCiy2aW7ge6Rr1KLmWRyoiqrooAXZPXKUtv6G0XLwbSGQE2Y19BhYWEOK0DwSo1j3HzSjPhzhSMra6ZBvcAna3UfC2xY57RU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022645; c=relaxed/simple; bh=1ukRFTHBXzQDwdqZTMPmiLVbxm5h2A6hbbk/Qx87Ehk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V/LNgpMqKkSBfoa/m5l/qOg25p3SPJWEfO5HQ+eYcsCefu4IJEQBuM3c6rBKyboMIDsYK1Ag3M0vHsK6ZH7oT13VwcQBB2BFE7zYgE5p1Q3jAxXOI3tnmJj3cFM5OyKKoaXckxdiymIrULLq4AMhKBh2UPH9I5Hf8MzLkXVWdMw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=wLpEiSBl; arc=none smtp.client-ip=209.85.219.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="wLpEiSBl" Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e0b10e8b6b7so38463276.2 for ; Fri, 26 Jul 2024 12:37:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022643; x=1722627443; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=KGNJUeIXrd5N6wQzpzOyY2v+zHYUKNT6NIwGolqwReQ=; b=wLpEiSBlpe3YBGKoPuQ4BqnbWsDnCRhkW6nMQAlJIlm/yzogsxHKErTZ3NPguvrI6X e9YjyRLqxAD+eEbZDb3GRPi+xv11ARKR6zExWAmzQu+PhHYnuXZ4xUp1taH/1e7BsQzK pImhYXCR8rcfNg9Qix5vupb3HnLvAE1p8QW2cIgOlleLIf+2QXMDugrd4JCH0alvXHD6 7+B8WSXMn9KpuQOtpREKj3vuT4P6WoPDkoONrg5sAmQidcH/anJtG2qlZi8gWI1bCnsu OCn4ElCK8PMxATi96C6vIpZttWrZbfOYSZSBkV9GHAPjrVmJ6bhNSdjMwnP6MX/GMP/1 fJug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022643; x=1722627443; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KGNJUeIXrd5N6wQzpzOyY2v+zHYUKNT6NIwGolqwReQ=; b=L0Hb2PB9LL21RVSufRPMo68ra6x2h1B9h1yGFJq5WaavXI0kidlJ2+LRuZZZBQeRWZ x4wADo1Baqd9pl3bgXIehrPf8A4IiDMxs+jDeQjnoMaCB+9dpzI/eheGdfKtnzGC9QYW H+tX7pOZ1R5rk0ljJZaGD7Ad/+/xzqvkKladeTvrpa5tjkw4//1IXMrkTJDMYAwIo+/X SRd0dOevWAshqBn54sCUyDx8Z3VgFs0AJwV9Yp2ZLw4Z+cXPE8eaWW4XDfg0bIEipfAY 8UuZqpftntwRz23WKnMhfp80EufZHYbezsw53zQRjBFNnjql2qIjUcWBevRrnMjaYuGg q+vw== X-Gm-Message-State: AOJu0Yz1+o+mZKe+vkGnqqbuyVBVa8cCzR+EblMy7hhFp1PQAVdNtjF6 LbiXip1IuNOiXyzzl3h1DIZYkBGQ9Gus31nB1gwz/GSos5fS+rEiGMlbjTb+sgQf8YLW/Am4maO N X-Google-Smtp-Source: AGHT+IGIZheH/Zs8eWd6GxJ3KLEDU9r0CClxj7o+gRh6RJ1/mgpSh8qkAqvIm2WVsZ9LpyhrLMKZUA== X-Received: by 2002:a25:a305:0:b0:e03:63d0:4516 with SMTP id 3f1490d57ef6-e0b5460dcddmr579019276.57.1722022642725; Fri, 26 Jul 2024 12:37:22 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0b2a70d174sm845794276.47.2024.07.26.12.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:22 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 43/46] btrfs: convert wait_subpage_spinlock to only use a folio Date: Fri, 26 Jul 2024 15:36:30 -0400 Message-ID: <2c87d2780fd99842891de98c8d2337ea2436333d.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently this already uses a folio for most things, update it to take a folio and update all the page usage with the corresponding folio usage. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0cdb0b86e670..80022a8c718e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7186,13 +7186,12 @@ struct extent_map *btrfs_create_io_em(struct btrfs_inode *inode, u64 start, * for subpage spinlock. So this function is to spin and wait for subpage * spinlock. */ -static void wait_subpage_spinlock(struct page *page) +static void wait_subpage_spinlock(struct folio *folio) { - struct btrfs_fs_info *fs_info = page_to_fs_info(page); - struct folio *folio = page_folio(page); + struct btrfs_fs_info *fs_info = folio_to_fs_info(folio); struct btrfs_subpage *subpage; - if (!btrfs_is_subpage(fs_info, page->mapping)) + if (!btrfs_is_subpage(fs_info, folio->mapping)) return; ASSERT(folio_test_private(folio) && folio_get_private(folio)); @@ -7221,7 +7220,7 @@ static int btrfs_launder_folio(struct folio *folio) static bool __btrfs_release_folio(struct folio *folio, gfp_t gfp_flags) { if (try_release_extent_mapping(&folio->page, gfp_flags)) { - wait_subpage_spinlock(&folio->page); + wait_subpage_spinlock(folio); clear_page_extent_mapped(&folio->page); return true; } @@ -7282,7 +7281,7 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset, * do double ordered extent accounting on the same folio. */ folio_wait_writeback(folio); - wait_subpage_spinlock(&folio->page); + wait_subpage_spinlock(folio); /* * For subpage case, we have call sites like From patchwork Fri Jul 26 19:36:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743112 Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.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 EA3AB1552E4 for ; Fri, 26 Jul 2024 19:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022646; cv=none; b=rVDVGo9SWvgysmGiWDlKittJq0mQz2/NQx1xI7lZybT2LiLmGH1y3qZCHWqqiPMpAdH/ZvXDbAzRAxMe8/GBcg1SHLO9Jd6fd+VRoY+gDYTyiyiZl9uBS8QBfEEuAsl1WBKymlSpiwB8lhNL8r0ylfHQyQ8r5lEe5WdWnAWSx/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022646; c=relaxed/simple; bh=2CYokru1KOIzGaR+kYpzm6XUamdiCZ5kw+OFy8OFq3Q=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=STgzeAvRK8TUrU4KjwIdqYhelyy8AwdcCcnD6j4DY7IKhTU3ytfE6nQnJNzC4la7s0IxdATjHp8/YKjq5AwcjfpE/EtewuLt86fGC2kPQ8ZB2bXx1hNRwGKmlvZPSxZfQONsHsyTyOaSxqt6Y9AgG1nOdEJ4zzkHrY71PH5SrbQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=LzZi1bpz; arc=none smtp.client-ip=209.85.219.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="LzZi1bpz" Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-e05eccfcdb3so43561276.1 for ; Fri, 26 Jul 2024 12:37:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022644; x=1722627444; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=znHk55CvcRk1eRAfKmKo0u4zO8N0q6ASd9YRTunmw2k=; b=LzZi1bpztTExyXrTZaOClJLdHer/Vh/CxPuE30EAWjsvtLu2EmH+elibu8aToUqVKT xz7QDLWwM/6FRrQ1mdj9u2jwFMjn7rhMl3fhM+qu2nvgdOMLyy1qpuxyRcLRmQcCSsIH ofgeqb7/YJ4piyYshhVdiWqa6BJDV/wIUeN4ffS9yqZdgripGj7Iq9NymF9PQu6l0bwc Gz0etxgoZ0hnVOKak0m+3jrOoynYxiUex/UX0ecB8Uag7mJrQAODMB/NKytw/ox1sI08 zDt7H8UcOq8ojg/cFjF61lDT7oASI/3Iv/6CypuGSdQFk+RAFnMDl8q3i70CD+8qEcT/ t6oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022644; x=1722627444; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=znHk55CvcRk1eRAfKmKo0u4zO8N0q6ASd9YRTunmw2k=; b=B8g3a6bn/bGdA6J796SmjUIR84SXdjrxPlcYLb7Wje0p5fU85Rgq4PyypVs1cYwNPd yZ0JcMyXBOxIuFTgqFlfr1AgfapwIkwlHVcWnPCfO5EPkwVWmJaUdctMmGxCxj9APunf ++ZYiA5VqLpRQvc+33H9INN80XSgFziMweDsxY1CdwOuBtWBdi+CyXnYMRBKfmS4zXOc VCV04EA1qFjpDPtfKpvL9yRCFhjK+DelhzZ9DJJGW8SqEV45Eeg5IZ3Ke/ms8Qvb5UuV HfO2sP7VoZfFCe5T8jGUEE+hrzoRnBjZT0I/lDxTmt6Uf5DbJxMa6WHc4zFuwTOsxdxn Y0vA== X-Gm-Message-State: AOJu0YynEujB5rV/CcNZXfpHBqR9R7ytt2QvcBu68pBcVmhg/xrSmiLR mxn5Xzmn+O9YBDmaxsoykr9kNqlIUbiCDG4jplQ4abPhFuiL/IO0f+qTfB3nzad9r014C1BWS61 C X-Google-Smtp-Source: AGHT+IGoaqwufS5j/zmBL47wmLmvHmEGLu3s5OItxHsD/kKymYaZYqMOBaNboQtGuS1TW757t4jEsQ== X-Received: by 2002:a0d:c983:0:b0:62f:945a:7bb1 with SMTP id 00721157ae682-67a0a323dc1mr8646947b3.42.1722022643924; Fri, 26 Jul 2024 12:37:23 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67567869beasm9889097b3.40.2024.07.26.12.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:23 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 44/46] btrfs: convert btrfs_set_range_writeback to use a folio Date: Fri, 26 Jul 2024 15:36:31 -0400 Message-ID: <5a35f970d3a576b6f459cc88565d44dad94ef771.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We already use a lot of functions here that use folios, update the function to use __filemap_get_folio instead of find_get_page and then use the folio directly. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 80022a8c718e..2f14b337a7ef 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8956,19 +8956,19 @@ void btrfs_set_range_writeback(struct btrfs_inode *inode, u64 start, u64 end) struct btrfs_fs_info *fs_info = inode->root->fs_info; unsigned long index = start >> PAGE_SHIFT; unsigned long end_index = end >> PAGE_SHIFT; - struct page *page; + struct folio *folio; u32 len; ASSERT(end + 1 - start <= U32_MAX); len = end + 1 - start; while (index <= end_index) { - page = find_get_page(inode->vfs_inode.i_mapping, index); - ASSERT(page); /* Pages should be in the extent_io_tree */ + folio = __filemap_get_folio(inode->vfs_inode.i_mapping, index, 0, 0); + ASSERT(!IS_ERR(folio)); /* folios should be in the extent_io_tree */ /* This is for data, which doesn't yet support larger folio. */ - ASSERT(folio_order(page_folio(page)) == 0); - btrfs_folio_set_writeback(fs_info, page_folio(page), start, len); - put_page(page); + ASSERT(folio_order(folio) == 0); + btrfs_folio_set_writeback(fs_info, folio, start, len); + folio_put(folio); index++; } } From patchwork Fri Jul 26 19:36:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743114 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 08DB015530F for ; Fri, 26 Jul 2024 19:37:25 +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=1722022648; cv=none; b=iywv9Yar5I6rIs/jEh0BcFXQdJmIljnHlAEDZu4arUheYMXbh5CsBgErAnQJVjbwBoZG3VrhffiFEo7qnTHi/y8o8WP8bcC0X7oJzYkq1U05Qy0K/dzkmmPRSzxkcQT/9Xvkq6Ti0KTfP6mvCHCy9njiMja2/Tm4PjX3WWMkNgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022648; c=relaxed/simple; bh=sSHhwu5lN1rA+LbUyBsY49n12Ou4f7yaJSrTLBDjMEs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BpvRlHFmeRa8H5xnbog6KtFwpQZKUvWjcIJXiBmui6naWAdc0KE1I050C/mtBQ3bg7xhUcyqLrY0vAqOY7vBkAf8tAwLwI66Vqg4A0BsURwiEB+pJLDGHIwdk/MMgk12BwNrjwUxRbXfcKVAHRP+ZhX46q2LZhi0LUTh53ykk2k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=f0c0LkUH; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="f0c0LkUH" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-66493332ebfso311087b3.3 for ; Fri, 26 Jul 2024 12:37:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022645; x=1722627445; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=oS99JkcYohsJ1gPjAyz3LxCZjiAwwWlVR03yxei/AxY=; b=f0c0LkUHuVNE+H7nbbTCS0ZMxc1x1uzF0x0zYVTtKhKUCGugTrQQMO/DFjBK43Mwwn uagESp42eOyk7SyRk1czIuzi0QNP27Azw+YlWOEgH2M4buCcnNVZNwN2XQx9VKPH31pw xzIrfqckWYyj/d9R/i4vZRqc4M0fDzO6fP7wyWDsQFfXjaA2XYvoywQyYHIkB9yotZXz hYnRXc7nUcD/x6erhtpnnviCCuNwmjMvqmObD2FtlB9k+aN1yPZP9ITjXzul+w7Du1sD 2dogWqm9JRXdFFKzmgwpjOl44icR2wYcfJYjbxTkd1e66dkIZ44F9uYZNhVB+gQVJ2HX cADQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022645; x=1722627445; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oS99JkcYohsJ1gPjAyz3LxCZjiAwwWlVR03yxei/AxY=; b=WghZpXcGJmh4BgkO3KeTDzaGKW5C/rlh4zDB/n9OJizGkhAPixAvLMjXsJMfz2KDgt QfJ6bKn1v3ihq9avHuz4q6lX5PPB9mpbrWVsgEJegQhqrPVU5dJ7u4N7z+y8L3ZQl5ek MOtH1fFWRNMwlah/flDd7TFYrsF/aFOoawZ7X+vBSb66xrJHTSCs0au1RJWwGiKQWMlG uOzjFr/x5x+bA6bf178s0RkKJu8Ndx9T1aXw0xnTD1LnvO+SM4UbI/77KJIx/vQr4V0a BAkVGwBGG/Rv4TjlZzXEWj65XKxPBIvZoqf9smOCJBPWHJyWQdS7TPUP2KTmUNOVV1C6 IsPw== X-Gm-Message-State: AOJu0YxrNj7qiGtkEao1YEhG0M29k+rMN3QpmEwHt5TzLwaV084IbHtF iB4n9slcXJG9ExQSUvdUVN4Z6E5KgFJpU8u4asR9uacsnLz9Z+/J4uf5dzwDXJrdLK3qKxj4zQm U X-Google-Smtp-Source: AGHT+IG/zb6XrQORL42RZX5x9WXskpra+dh0TfVoCWkNf0iCXOJvqQOPsmhgTpKx8Cfj9mpp8MS6JA== X-Received: by 2002:a0d:f685:0:b0:66a:b6d2:c184 with SMTP id 00721157ae682-67a06ede4f9mr9294377b3.16.1722022644958; Fri, 26 Jul 2024 12:37:24 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6756b024db3sm9864687b3.102.2024.07.26.12.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:24 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 45/46] btrfs: convert insert_inline_extent to use a folio Date: Fri, 26 Jul 2024 15:36:32 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We only use a page to copy in the data for the inline extent. Use a folio for this instead. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 2f14b337a7ef..c019beb7d9ef 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -495,7 +495,6 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans, { struct btrfs_root *root = inode->root; struct extent_buffer *leaf; - struct page *page = NULL; const u32 sectorsize = trans->fs_info->sectorsize; char *kaddr; unsigned long ptr; @@ -555,12 +554,16 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans, btrfs_set_file_extent_compression(leaf, ei, compress_type); } else { - page = find_get_page(inode->vfs_inode.i_mapping, 0); + struct folio *folio; + + folio = __filemap_get_folio(inode->vfs_inode.i_mapping, + 0, 0, 0); + ASSERT(!IS_ERR(folio)); btrfs_set_file_extent_compression(leaf, ei, 0); - kaddr = kmap_local_page(page); + kaddr = kmap_local_folio(folio, 0); write_extent_buffer(leaf, kaddr, ptr, size); kunmap_local(kaddr); - put_page(page); + folio_put(folio); } btrfs_mark_buffer_dirty(trans, leaf); btrfs_release_path(path); From patchwork Fri Jul 26 19:36:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13743113 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 EBBD515530B for ; Fri, 26 Jul 2024 19:37:26 +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=1722022648; cv=none; b=QD2pqw1iSdXSdcpuOXJsG1fx/c6PxL0TLuKGPGbpcPlbiqLiaQbs35ZoVqcxFe7kJexsCIEiGQEteZ4tqRx2UokYyijV76HiTEmqztwaFupuntSRwkTh5T/0IJ2Q5ivEXIOARayY33udrM0wgncpJ3lFit8fFzS5UMNTcdD9KuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722022648; c=relaxed/simple; bh=Inb0aqEP/SP7FGHHn8cWmY934wEXDaZxEhT4K//JPlA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eccAEst/UPEEGAcOJw17KFW63ljMj3XoUTXhr3C0cZDQMMk6DNLDAwuKVac+yk3SMO00R7TxR4k6+IyTwNjL6nZKXJUVlfkByGMGzgn6YtW9EWPa1Zha/CUTGEu7/GVqWUOBoXj2oB3J7a1/OOp8KNuyIVH7/0CfoNdQl2RXL5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=N5m6nC9P; arc=none smtp.client-ip=209.85.128.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="N5m6nC9P" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-64b417e1511so235387b3.3 for ; Fri, 26 Jul 2024 12:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1722022646; x=1722627446; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=RB4ZcR9rQuKZdUzsoI+3qZXPRxW935rVZwMLYS2Gde0=; b=N5m6nC9PS6RgeFDXWqmQCn3i3PrRA585V8QewVT1DL6jTPFK9x6QLbFoHSLPBP/A8+ 9/qv6PqD8YVEUPbaBkoWkxAeuq5tFQm8Lzc0lEaUpm2UD9vETa7roLVzJReoD0FiS5vQ dxQLQRWQ/FrhxsiElFhIirSNBw/oLCGqyYTFsB2FECL7aOaBZ8K3/V2vYhh5du4+MuoV 3XxxaAqbmKDwyIuYKUO/s8m+dh8kHNvkoky/LTtQuHxCNQM4jJtFLrpWfGoQjo6c0hh9 SuCQOIaEy2waQCVt3ILJd74tx9bOe14lC3FjOvddaziM6r6TQELZdc9X8grOODwsgOw7 Rccg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722022646; x=1722627446; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RB4ZcR9rQuKZdUzsoI+3qZXPRxW935rVZwMLYS2Gde0=; b=X9g18RdOOe8PvVZFTG4g9L2EPTT4Q7gEihjIgwkQco8RlnSohIbP6n7X8GCNvIVprI 0ioY9nHw4cF+e38C0tQ6AvqjiYsgYjUEv26PAy6OuVd/VrXvYGmC0YUtegdSTXyudlJs alHJo6auMBeJpoDcmO31NAPiP7vYf5ybT3aVaFrV9SAl6Do89YS8YY9jkwC5noZ/jodW sKrFRr53b5Jsd9U+c805sNri1VRfhaWsm3sXydvO/OxJ2XnVt1whAMHPkY/h+44R/nW9 qeeo93mHhWuxVKP2EJnAnw6N05QrnMz5Uok1df92lNjgce/QcqnLo8WMohulacJqwESB d8YQ== X-Gm-Message-State: AOJu0YymEGDyVjFCw97NqqO2z8Gr9U1+xMA9v/QCwcDDArY6M8eB9CZI xK+btLem5Xdyizn1u9jd+VjC+Yo68hshG0n4WjSBrYGoCWlKg8cKdZapupRrnUG+AgnKUbxx24H W X-Google-Smtp-Source: AGHT+IFAGdRdwD5ZG1Su/X2ftLx6SRYvoiPftpDuvkkR7y0NSF2w1nCWuR8ZPEC58QlkTPlK2l9GRQ== X-Received: by 2002:a0d:d007:0:b0:673:1ac6:4be0 with SMTP id 00721157ae682-67a0a3231d1mr9188067b3.44.1722022645909; Fri, 26 Jul 2024 12:37:25 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-67566dd8f25sm9793087b3.29.2024.07.26.12.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 12:37:25 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 46/46] btrfs: convert extent_range_clear_dirty_for_io to use a folio Date: Fri, 26 Jul 2024 15:36:33 -0400 Message-ID: <991405b7951dd3730058041c65aafd88ca023add.1722022377.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of getting a page and using that to clear dirty for io, use the folio helper and use the appropriate folio functions. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c019beb7d9ef..79888ae8d883 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -877,19 +877,19 @@ static inline void inode_should_defrag(struct btrfs_inode *inode, static int extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 end) { unsigned long end_index = end >> PAGE_SHIFT; - struct page *page; + struct folio *folio; int ret = 0; for (unsigned long index = start >> PAGE_SHIFT; index <= end_index; index++) { - page = find_get_page(inode->i_mapping, index); - if (unlikely(!page)) { + folio = __filemap_get_folio(inode->i_mapping, index, 0, 0); + if (unlikely(IS_ERR(folio))) { if (!ret) - ret = -ENOENT; + ret = PTR_ERR(folio); continue; } - clear_page_dirty_for_io(page); - put_page(page); + folio_clear_dirty_for_io(folio); + folio_put(folio); } return ret; }