From patchwork Mon Apr 3 08:47:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13197808 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72068C76196 for ; Mon, 3 Apr 2023 08:48:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D4F56B0072; Mon, 3 Apr 2023 04:48:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05CE76B0074; Mon, 3 Apr 2023 04:48:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E19636B0075; Mon, 3 Apr 2023 04:48:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CE0216B0072 for ; Mon, 3 Apr 2023 04:48:18 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 91526ABDE3 for ; Mon, 3 Apr 2023 08:48:18 +0000 (UTC) X-FDA: 80639453076.13.995C25B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id D7895A000F for ; Mon, 3 Apr 2023 08:48:16 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VOVUClk0; spf=pass (imf15.hostedemail.com: domain of cem@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cem@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680511696; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=C71pWMy4jbYBxZot5uSQLjx5KowzEZh2qlPuFcp0qkg=; b=S3q10AH0tQTDWJqnaT3E4vndb5pi6dtLT8SaM4Fu6a74am6VrHF/XlvXfeGyoL8BSz8IqB k/o3J+zYNHFj/+2iEwV1hIHTPpXDjAhEqqXJluK+pj/ArLRpj0sxLkO/X0BL6BRWegjidS qGsu+ie/1MXntOU7+kccLdBm/sNH/10= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VOVUClk0; spf=pass (imf15.hostedemail.com: domain of cem@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cem@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680511696; a=rsa-sha256; cv=none; b=LCdSxxlH+hDM7Rs7cCAtvAxhT1ZuVxkj64yuh4+3warVo0yeAcnxBH+RLpsIeB1lmKOPim f+saE1TLZq6Jr51VeL/eoDah3o3cShqToVdSU8qwJLzL312orF2zmacDEO8o7BQIDsUftW yojk64SEG4qDLP4nID+sxLQWgTPn48w= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D51B860F5A; Mon, 3 Apr 2023 08:48:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6B30C4339C; Mon, 3 Apr 2023 08:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680511695; bh=+0zQcAzsOXQwjktjWL0vkvwn0ez4Qoz15/Uz4pSYjMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VOVUClk0KIZTDvpV3mvscFtpPF2E9p2tSjwXXXd55omX9+Sfl9gFfAWAZmnCJ8kqJ FxLGZtvPAUrXSVeV7xmWw6dWcj/NjHCCyhwJrkB5ZGVgRZXF7cKRpcqbZqwv9HE/Yj r44b6K6TLCdBm2O5W/xRmSIuu847/MGlQJyDQbZIbalse40bineyZYJc02fS/00J2f rDYithEgtWpu8kQ/IRRVEL/cnARFe6+xobqFzCf1DZuE8siuUrspndsHw9PpshtPgv ZXmX35H4eoi77BDXgPX6dim4BEdyK5CK0aISXVTRslWBmKhDm/03ApltyBev1YNESx gXMRZcHXp811g== From: cem@kernel.org To: hughd@google.com Cc: jack@suse.cz, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, djwong@kernel.org Subject: [PATCH 1/6] shmem: make shmem_inode_acct_block() return error Date: Mon, 3 Apr 2023 10:47:54 +0200 Message-Id: <20230403084759.884681-2-cem@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230403084759.884681-1-cem@kernel.org> References: <20230403084759.884681-1-cem@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D7895A000F X-Stat-Signature: oxf7w93c3apfcecign44dc8ps7daqqiu X-Rspam-User: X-HE-Tag: 1680511696-250337 X-HE-Meta: U2FsdGVkX1/9sc8LxUXtFLgjTyj9B/eK3MTKtqMCD68xcHHXgXRVJuiFCs5FrOMyZuPoDuiNwhyNFjl9D7UuD091TbBlUp9h8wbUuy1SROikHjdoFvw0AUybMcSnBrTUd6+pG7W7ETKcNVnEl4kJ+On12Vzd3WoKbkcNg0tWan+05a5liB6jRXzY/tgjH1Yk3DQWGRhkS2SLLjzV7q3ZYtg+5To57VQ4oxrpmfFxmQsGcNpLNqMqrceWopQoUcwxSJXu8ZCDvK+mZRuRYPPB3xs0dpsfUW/yVQ4u8eyrljBze58gKEK/tT1RhjLWipLmA0/V/vw0Fxw6TqTgN+5l1n3VQWMv89kIki+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bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Lukas Czerner Make shmem_inode_acct_block() return proper error code instead of bool. This will be useful later when we introduce quota support. There should be no functional change. Signed-off-by: Lukas Czerner Signed-off-by: Carlos Maiolino --- mm/shmem.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 448f393d8ab2b..0e63ea5f6ce69 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -198,13 +198,14 @@ static inline void shmem_unacct_blocks(unsigned long flags, long pages) vm_unacct_memory(pages * VM_ACCT(PAGE_SIZE)); } -static inline bool shmem_inode_acct_block(struct inode *inode, long pages) +static inline int shmem_inode_acct_block(struct inode *inode, long pages) { struct shmem_inode_info *info = SHMEM_I(inode); struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); + int err = -ENOSPC; if (shmem_acct_block(info->flags, pages)) - return false; + return err; if (sbinfo->max_blocks) { if (percpu_counter_compare(&sbinfo->used_blocks, @@ -213,11 +214,11 @@ static inline bool shmem_inode_acct_block(struct inode *inode, long pages) percpu_counter_add(&sbinfo->used_blocks, pages); } - return true; + return 0; unacct: shmem_unacct_blocks(info->flags, pages); - return false; + return err; } static inline void shmem_inode_unacct_blocks(struct inode *inode, long pages) @@ -369,7 +370,7 @@ bool shmem_charge(struct inode *inode, long pages) struct shmem_inode_info *info = SHMEM_I(inode); unsigned long flags; - if (!shmem_inode_acct_block(inode, pages)) + if (shmem_inode_acct_block(inode, pages)) return false; /* nrpages adjustment first, then shmem_recalc_inode() when balanced */ @@ -1589,7 +1590,8 @@ static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode *inode, huge = false; nr = huge ? HPAGE_PMD_NR : 1; - if (!shmem_inode_acct_block(inode, nr)) + err = shmem_inode_acct_block(inode, nr); + if (err) goto failed; if (huge) @@ -2433,7 +2435,7 @@ int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, int ret; pgoff_t max_off; - if (!shmem_inode_acct_block(inode, 1)) { + if (shmem_inode_acct_block(inode, 1)) { /* * We may have got a page, returned -ENOENT triggering a retry, * and now we find ourselves with -ENOMEM. Release the page, to