Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1527170lqp; Fri, 22 Mar 2024 20:02:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXZ4gyA7Ez+FIKaYmLNrYKnwuNgB+XtPKP6aFQ8ZPu1T29p1D7YCJFt93zyIqXWjyKdJznw7SQ62GhPbWdZWXQX5WPUcCqNY4i8sv8rg== X-Google-Smtp-Source: AGHT+IHDHxr9D4UGHf+sTEg5xzOihK+y/3U15n6/AVDB/YqfMryci0UBHqb+ibGLwdzCZM3QxlNz X-Received: by 2002:a17:903:90d:b0:1dd:a3d4:9545 with SMTP id ll13-20020a170903090d00b001dda3d49545mr1827516plb.54.1711162941907; Fri, 22 Mar 2024 20:02:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711162941; cv=pass; d=google.com; s=arc-20160816; b=Q4uAGSEOCwmMrRZzUJ2F4yqzn85sb9ahqOtcPEos4pIp5BDE2tUx0RGlFj93Avbqa6 XHOfljkloycdbvRR2+5v/hpge51Z7KA0KZleCuaGbmOM6+6r0dzcdEqmyHvSANP+3RSM /pc6CLmQEtPHvNqNYyQb9yhtBihtwZvGthzV4L4gHJFJ87+YhyWNVx4dGUpgNS36dIUQ ZRmThptNw4nEuN3wEcSUhnCTL1MdB2IsX8xPyF6Bbg03qUAGC/nVSp9vISFrF7+7jQOh My/kVg+MdGILW4h84pjhNQ7ve2XveVTkTylyjhFAXzdX47XrMCwZsyfsT3byxUl5hmh4 v0jw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=1Tm7qLFJpMIaoF/y2FtCT5jDdjOozfLC0kR1KO8xRms=; fh=W6COFBd4BX4Q4YpnsinfP4Lifuq45kIfChsHXFM1YEQ=; b=Gu3UYN2AAnLUUKysov+rs8t71nLLu/0TTG6QyQHBI6u2UiR13ksWph0dUqojivetQK A8oWadHMtfuZ46tdfnOPR3h47MRpgJZrnFWXMOEN9sy6ObBtQF8P7MpCLwyAuxD3BD5B AB4CpPbVuS+vi9MSLJ9A1UMIM3P0osCAfg1ukAcryBP3VYqVr4kL+YSqGqoRdK9Db/AS zmgiLMTfm8mW+yX5aqBQ69ZmCO6gpY6gi9qN9R91+IqjHm9H0jNi3Sq9cNw2Qs/csNkd 71aSCPVOhyc0T8ZyoClnVv6MG62QydRi3DTBI3TAmPeCwdrSr2/or4ZC491Hf3pAOmep AxJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uWLDtJig; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112197-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z9-20020a170903018900b001dd998d420bsi812201plg.48.2024.03.22.20.02.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 20:02:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uWLDtJig; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112197-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8CEE4B21536 for ; Sat, 23 Mar 2024 03:02:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C83A4A34; Sat, 23 Mar 2024 03:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uWLDtJig" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FB2E46A0 for ; Sat, 23 Mar 2024 03:02:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711162927; cv=none; b=JJG/xSqntdI3OyhfgHS7dEZ8K/vud5MN+vwggKTSAtun69to/n7cXL7KTNSvJin1OOxsFot1inlTM9naUN9JgMAUtU8OU6lQUgSlFw8CjsLZ/NIMYFa/SAK22PznFuC/y3CcXYB8y5VQ4fUskSzayl9XPiPYdiHi3a0JigAm2Ro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711162927; c=relaxed/simple; bh=5GIJqxzxojFxdQ6uIIWjC1JDm5Dr90WPqPXlxSOPtyM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MGe5vQh6t85aOaRrC5Jcc/Ijj0nD0+ZZkUgfqTgjyknVPe8zGx2N/lkJznp0RBaYSluIJXZDeqcAgO6UBrmOYL/oV6kYGKyR7r6lfOwkW4DlpwTcIndksyLgPSvKLdwyP68MCmGgw7ZQbmAw/KGas6f/uMhy5Yo33/YXBMpSqQA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uWLDtJig; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5955C433F1; Sat, 23 Mar 2024 03:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711162926; bh=5GIJqxzxojFxdQ6uIIWjC1JDm5Dr90WPqPXlxSOPtyM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=uWLDtJig6t44CSErmiQQkXOyHKs95ufce5/43FubolkHCsdkBYcST5Qcs6T7TtJez xtdtaLI4R/16MI1KQcvxZ4XF7gXKLO2b4VqPNFuPBjrOwEIcnfJOyErcjz+ypXApdz X+jlvqY/V4b4jh73X7vJPLc/AcnoWZldZygvSJMO7ckF5pTWg7qiObA1DsFMMlOkli YbaDlIvwK16FJ5TYZwHaf6rMi+6SUJa8GUirD8eklv8qYE2kdcE02Y54JQE9iLMPlw 7g1jKBVEeIYOLNADr5eaBh52FBj1OqVShYF9YfRCxKZIXVdNXUSLdR2RNDXSa2Ucru UOzDh/Z6IE8qw== Message-ID: Date: Sat, 23 Mar 2024 11:02:04 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] f2fs: fix to adjust appropirate defragment pg_end To: Zhiguo Niu , jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, niuzhiguo84@gmail.com, ke.wang@unisoc.com, hongyu.jin@unisoc.com References: <1711087390-23645-1-git-send-email-zhiguo.niu@unisoc.com> Content-Language: en-US From: Chao Yu Autocrypt: addr=chao@kernel.org; keydata= xsFNBFYs6bUBEADJuxYGZRMvAEySns+DKVtVQRKDYcHlmj+s9is35mtlhrLyjm35FWJY099R 6DL9bp8tAzLJOMBn9RuTsu7hbRDErCCTiyXWAsFsPkpt5jgTOy90OQVyTon1i/fDz4sgGOrL 1tUfcx4m5i5EICpdSuXm0dLsC5lFB2KffLNw/ZfRuS+nNlzUm9lomLXxOgAsOpuEVps7RdYy UEC81IYCAnweojFbbK8U6u4Xuu5DNlFqRFe/MBkpOwz4Nb+caCx4GICBjybG1qLl2vcGFNkh eV2i8XEdUS8CJP2rnp0D8DM0+Js+QmAi/kNHP8jzr7CdG5tje1WIVGH6ec8g8oo7kIuFFadO kwy6FSG1kRzkt4Ui2d0z3MF5SYgA1EWQfSqhCPzrTl4rJuZ72ZVirVxQi49Ei2BI+PQhraJ+ pVXd8SnIKpn8L2A/kFMCklYUaLT8kl6Bm+HhKP9xYMtDhgZatqOiyVV6HFewfb58HyUjxpza 1C35+tplQ9klsejuJA4Fw9y4lhdiFk8y2MppskaqKg950oHiqbJcDMEOfdo3NY6/tXHFaeN1 etzLc1N3Y0pG8qS/mehcIXa3Qs2fcurIuLBa+mFiFWrdfgUkvicSYqOimsrE/Ezw9hYhAHq4 KoW4LQoKyLbrdOBJFW0bn5FWBI4Jir1kIFHNgg3POH8EZZDWbQARAQABzRlDaGFvIFl1IDxj aGFvQGtlcm5lbC5vcmc+wsF3BBMBCgAhBQJWLOm1AhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4B AheAAAoJEKTPgB1/p52Gm2MP/0zawCU6QN7TZuJ8R1yfdhYr0cholc8ZuPoGim69udQ3otet wkTNARnpuK5FG5la0BxFKPlazdgAU1pt+dTzCTS6a3/+0bXYQ5DwOeBPRWeFFklm5Frmk8sy wSTxxEty0UBMjzElczkJflmCiDfQunBpWGy9szn/LZ6jjIVK/BiR7CgwXTdl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U3A6GTum2aU3Gh0CD1p8+FYlG1dGhO5boTIUsR 6ho73ZNk1bwUj/wOcqWu+ZdnQa3zbfvMI9o/kFlOu8iTGlD8sNjJK+Y/fPK3znFqoqqKmSFZ aiRALjAZH6ufspvYAJEJE9eZSX7Rtdyt30MMHQARAQABwsFfBBgBCgAJBQJWLOm1AhsMAAoJ EKTPgB1/p52GPpoP/2LOn/5KSkGHGmdjzRoQHBTdm2YV1YwgADg52/mU68Wo6viStZqcVEnX 3ALsWeETod3qeBCJ/TR2C6hnsqsALkXMFFJTX8aRi/E4WgBqNvNgAkWGsg5XKB3JUoJmQLqe CGVCT1OSQA/gTEfB8tTZAGFwlw1D3W988CiGnnRb2EEqU4pEuBoQir0sixJzFWybf0jjEi7P pODxw/NCyIf9GNRNYByUTVKnC7C51a3b1gNs10aTUmRfQuu+iM5yST5qMp4ls/yYl5ybr7N1 zSq9iuL13I35csBOn13U5NE67zEb/pCFspZ6ByU4zxChSOTdIJSm4/DEKlqQZhh3FnVHh2Ld eG/Wbc1KVLZYX1NNbXTz7gBlVYe8aGpPNffsEsfNCGsFDGth0tC32zLT+5/r43awmxSJfx2P 5aGkpdszvvyZ4hvcDfZ7U5CBItP/tWXYV0DDl8rCFmhZZw570vlx8AnTiC1v1FzrNfvtuxm3 92Qh98hAj3cMFKtEVbLKJvrc2AO+mQlS7zl1qWblEhpZnXi05S1AoT0gDW2lwe54VfT3ySon 8Klpbp5W4eEoY21tLwuNzgUMxmycfM4GaJWNCncKuMT4qGVQO9SPFs0vgUrdBUC5Pn5ZJ46X mZA0DUz0S8BJtYGI0DUC/jAKhIgy1vAx39y7sAshwu2VILa71tXJ In-Reply-To: <1711087390-23645-1-git-send-email-zhiguo.niu@unisoc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/3/22 14:03, Zhiguo Niu wrote: > A length that exceeds the real size of the inode may be > specified from user, although these out-of-range areas > are not mapped, but they still need to be check in > while loop, which is unnecessary. > > Signed-off-by: Zhiguo Niu > --- > fs/f2fs/file.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 128e53d..0e7eac6 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -2609,7 +2609,9 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, > int err; > > pg_start = range->start >> PAGE_SHIFT; > - pg_end = (range->start + range->len) >> PAGE_SHIFT; > + pg_end = min_t(pgoff_t, > + (range->start + range->len) >> PAGE_SHIFT, > + DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE)); I guess we may check i_size w/ inode lock, it can avoid racing w/ append write or truncate. Thanks, > > f2fs_balance_fs(sbi, true); >