Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp925404lqp; Thu, 21 Mar 2024 23:04:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU0AKRBaOBBOCkQAsb4TBzzgCSuQxl8jsJds7dINTxe53vjdzNBT4GMnKPgfa2nRGFFdWUOlWXwaLS9pPWOslTG34GGsFbSW6WPnmQPcg== X-Google-Smtp-Source: AGHT+IFvowsbsfXvDjkIPTvYZpf76VCXSDqsIk3Q6+xWTtOWhlRS/8SIEVD7/kPOFrpeitmujOyd X-Received: by 2002:ac8:5c0e:0:b0:431:1ed1:7df2 with SMTP id i14-20020ac85c0e000000b004311ed17df2mr1575556qti.13.1711087469576; Thu, 21 Mar 2024 23:04:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711087469; cv=pass; d=google.com; s=arc-20160816; b=deLN7xSRvHYmi1XOy/+a2Tqhj3c8OU3YCV1PJHGnevJov9aZkd1X8OeBbfitsjP2k1 zhITuUT/tkQq6JkK5JcpB0gBhWM+OP6sfxbok5RmsKiJlyZzpGxM4vzqiiizrW+9dZ/g +UZLPWhQrektw/BOYTd74PlEDN+qekvhooFDrVP+lbFPcE1Uu8IX0rUQMI1Tf4afK7C1 al54Our7WlNGWapq2v9+hWg5icQ50GB13Yk8mnE64DFQkLK0JJPqddRW7gI6OiAe8OBv 1W4XrB8Vp2vfUkN99eE8By7LTf7ZlxyYbzB7M8Lv2SPktir5myHNZ5Eb2zpIhxIy6sTH fE8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from; bh=VtC/YVu6XzE84dntAhY1j7UFHanWCYhwTekFoRytlZU=; fh=r88ULmOhzmh3DE8RgcUXK+PF5Q+3czCYkx5yGhGfkR0=; b=v2jvuPPFp/DY2waFJjqn9P09rZpebqy33+MVcT0yZQVkV2+GRzJ0CUQvbbjF0p3LOQ ULAGw7VO3JDt5MXq7WU0GW97cpPuCpsmUKzq5fCe6iblNrEr9tzBHPSOMMpxbVFjNApM qhahqLi0Sw8J0m04qS37VRkJnjrZzXJRCp6XUTubg/AwGrGSuotYIZt2xlydyIEgL697 5Jhl/xN7ESGmtSzNslTcfnE6L+NQk693NpdcpmXYqkaTdG3K1ge9QfyfcbPpHXOO4azV 81bhLQGyPOMdpY42LKqrwootycdpjAUICxB+2ue+luGkMa3bl9MREK11s0rihrI1dO80 Cu6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-110978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110978-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s20-20020a05622a1a9400b0043127ff25e5si1334264qtc.557.2024.03.21.23.04.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 23:04:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-110978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110978-linux.lists.archive=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 447A61C229F9 for ; Fri, 22 Mar 2024 06:04:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C3D8C144; Fri, 22 Mar 2024 06:04:23 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) (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 B34DE65C for ; Fri, 22 Mar 2024 06:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711087462; cv=none; b=fBmmwU8LD7hQTuvW0dPBfgMRT53scMhZeZ6+QeOUTML3x88dSzE8P81cHbjdJj/AnYmk3+LSWrp0Qp9Z6m62j2ZEImckyYwP8hDu/PzM3Pk0oAWsQ0PNmWgSKkonizKtLH1eUBVuWYLHgOj6+x+i+VhJDqys+/Tpt0gU/FEo06Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711087462; c=relaxed/simple; bh=oymclslinvYkSdIJY8wyn9nZB7VJgipYqG8U7+so4+A=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=S4rSMIa8u58H7o7mXE513YumwWJ6aPcIYTnnWOyV9l3ODNtVEqK+286Op+sYfWeQk2zyIioUDQls7PFs4ypMwmWIa84wJ0G/xxcGCvBZ7NPQPCTIefw2Ie/8896gy/e9xzKDxmMmek0wMzlohJUc1B5pSN0UMdgdiRvme9dZnvA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 42M63LJl093516; Fri, 22 Mar 2024 14:03:21 +0800 (+08) (envelope-from Zhiguo.Niu@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4V1BY828Zkz2Lj488; Fri, 22 Mar 2024 14:01:48 +0800 (CST) Received: from bj08434pcu.spreadtrum.com (10.0.73.87) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 22 Mar 2024 14:03:19 +0800 From: Zhiguo Niu To: , CC: , , , , , Subject: [PATCH] f2fs: fix to adjust appropirate defragment pg_end Date: Fri, 22 Mar 2024 14:03:10 +0800 Message-ID: <1711087390-23645-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL:SHSQR01.spreadtrum.com 42M63LJl093516 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)); f2fs_balance_fs(sbi, true); -- 1.9.1