Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1224455imm; Mon, 9 Jul 2018 20:35:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdjV5zyzl3oha5mZN/Oo+TJsmHQ0tD1W7Uqzpb/vCQJoPp46dGSXuIhXN7+HJiCG/99w89k X-Received: by 2002:a65:5803:: with SMTP id g3-v6mr21411114pgr.117.1531193704652; Mon, 09 Jul 2018 20:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531193704; cv=none; d=google.com; s=arc-20160816; b=weK4wgEicc1UmxWsXfA3/H8Odg2jWds+KXDeqY+JqTUjHHCtyg6CP6YRt1sdCi6Wzz /8gmnVvz7K86e+KWmLukfhfzbsLnmPo64Zo9Smx3zYSbrzdl16RP+6lbd1Gn/2dF2QqR aRYonNzR8ZHGrPy7s8jR4UGnS4ZC4/FBzsvnRKqWiFR2Tecm+PQakBiqlIVN9pD6JRWC dBCueuVjEHG+oRfvVPG0DU+QdMtC9sMJL9nlJMnmoVZTZx5MhGrAdEJlyBNLazm0DPI3 0rU9YDcyWU+umV6lDCWupmHpRkNZ6hvUGRhrxIGCIdtVCFVGaabK8PcTgFygew/mCH9u gGFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=WsdLPdwvHqxlWUa/+V/y2YCutcj9kExp8LPWlKCa2ww=; b=LX0LEnnndEKA/RyYzZhgayVkV4uNqtzoQEkrhqDl8hXgLpYtlHCxezP8xM3GFph41j yPznJqcIa/IR+PVSJ5T3mm4n3edw4Yxfxv2Zsfp/pDamrMVkvndU22szeVw0PerUk1Vv 44nBw5ZzkgB6oiKBPwyq7D8Srsci18IwP6a5aY7Y3xIeJ8XCvEvIJZIh0uheIO0iWRv+ tFcR0X0PuE9T/vPe2GqX4E6Lh9TlxH79iEQ68sv73c79pvyhx7xxefaVUm6/KRmY9LZP 6iEJFx12uxHGnhHsM/pDYMWsPYxRiSaC4jOKTH6euLHzNPunnihebfOnpEBvhEFxfT6+ Np8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kwd8DT2Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6-v6si15591091plh.158.2018.07.09.20.34.49; Mon, 09 Jul 2018 20:35:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kwd8DT2Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933169AbeGJDeI (ORCPT + 99 others); Mon, 9 Jul 2018 23:34:08 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:37285 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932850AbeGJDeD (ORCPT ); Mon, 9 Jul 2018 23:34:03 -0400 Received: by mail-pf0-f196.google.com with SMTP id x10-v6so5234997pfm.4 for ; Mon, 09 Jul 2018 20:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=WsdLPdwvHqxlWUa/+V/y2YCutcj9kExp8LPWlKCa2ww=; b=kwd8DT2Qr5mDuK6ZdOVe0Ce/zmmnlcgS7ufvO31OR3hU1CsnY0Qh2DHoxTAb3WU5/N IJY0GxXJPzeB5ZZsu+zEg9tNRcJAqrX6vNtcweQWqJjQn4MKLwLScODAlIZfjOv7RJrX h0W+yauGw+jhqaIcCPzUj9AcYPr2/LXi3F/HMhTejdE5/BzVj4/RKbgKHYaftYR37frS lMD9XGcEgralV6IYm6PQleZHMLH8Zu6KVJ3jAhh5efMrUL0G93cV4MJxzVzHsLwtglAH DLuO8RbmTnq72OkweonEuE88hTWa0MT/YV/DAsA/qztTbHQYjwOVPyCfZzCjoUKD9GSQ jMfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WsdLPdwvHqxlWUa/+V/y2YCutcj9kExp8LPWlKCa2ww=; b=Ptoqiwwy8a7PTnkYOLpcMx2TvKlpURQo08+wHHBWZ29Plb3TlhiXiXCnUe3vHKoV3+ qHcfkizDHLlaXqXFBt4pO/TZjrhdtwGqj8SSQEBhl4Mg7E5yjCh/IDncWKnayNivxKOq Eb1lTftuOVpQiVhZSiGHvF71OnWhFuEugTB5s2cQ52gN/BMZKY5hdmi/yCcI449Lmcav 9dMZBQ0LZm6vMSPpFgxmTykCMZ3JYqu/E0AsBgYYHul+XxYzIklf1uqx4SLxksOkQAUf sT73AFJAhaKdhm+pviIZYf5U/T1Ys2XedpSaKJQWWjH5KPuQdBpKeQPV7atayJyfTltC T/lA== X-Gm-Message-State: APt69E2kSDAeUauh3JwtekdhlEK7jixQRbkYdLG4dIpFo4x71+/RYEu3 oAXfWYVUKxVbk5rcGMvpPISICA== X-Received: by 2002:a63:2c0d:: with SMTP id s13-v6mr21506830pgs.37.1531193643014; Mon, 09 Jul 2018 20:34:03 -0700 (PDT) Received: from drosen.mtv.corp.google.com ([2620:0:1000:1611:7129:1142:3149:848c]) by smtp.gmail.com with ESMTPSA id z19-v6sm24778961pfe.163.2018.07.09.20.34.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 20:34:02 -0700 (PDT) From: Daniel Rosenberg To: Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, Daniel Rosenberg Subject: [PATCH] f2fs: Keep alloc_valid_block_count in sync Date: Mon, 9 Jul 2018 20:32:42 -0700 Message-Id: <20180710033242.177557-1-drosen@google.com> X-Mailer: git-send-email 2.18.0.203.gfac676dfb9-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we attempt to request more blocks than we have room for, we try to instead request as much as we can, however, alloc_valid_block_count is not decremented to match the new value, allowing it to drift higher until the next checkpoint. This always decrements it when the requested amount cannot be fulfilled. Signed-off-by: Daniel Rosenberg --- fs/f2fs/f2fs.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 4d8b1de83143..5af955a8736e 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1680,18 +1680,20 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi, sbi->total_valid_block_count -= diff; if (!*count) { spin_unlock(&sbi->stat_lock); - percpu_counter_sub(&sbi->alloc_valid_block_count, diff); goto enospc; } } spin_unlock(&sbi->stat_lock); - if (unlikely(release)) + if (unlikely(release)) { + percpu_counter_sub(&sbi->alloc_valid_block_count, release); dquot_release_reservation_block(inode, release); + } f2fs_i_blocks_write(inode, *count, true, true); return 0; enospc: + percpu_counter_sub(&sbi->alloc_valid_block_count, release); dquot_release_reservation_block(inode, release); return -ENOSPC; } -- 2.18.0.203.gfac676dfb9-goog