Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1606411lqg; Sun, 3 Mar 2024 19:29:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUuYfcvXyy4m+g41hpzS+6QHH5oLCUCeVhfRVZdE8YcXSVK1DOApnNP5erItoBUou8hb3I77Ay1T2+LDuC9p1v73lc0aOPB/o5KdBqKpA== X-Google-Smtp-Source: AGHT+IFrvhhgayZflLVHSX9tqTE2fl7PG/mNX1r6+bExWlxOhWvxIZ+kbtl7EXg02491WQCNAWv3 X-Received: by 2002:a05:6a20:c90a:b0:1a1:420e:f26f with SMTP id gx10-20020a056a20c90a00b001a1420ef26fmr9736358pzb.22.1709522949713; Sun, 03 Mar 2024 19:29:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709522949; cv=pass; d=google.com; s=arc-20160816; b=HuTGxfVdjwUYrX4b8Antunz8s59z/L4SVBmT9f/u93r2NghSYn2HpnRRq9wPyOgpq7 YADwi/PHghYIZXJ/smrq1wZAiMye5+9HsNW9+1Rm9Rfet9oloCgWScwAGACZu8j/F4Db 9yzXyk2EHld5TiHuJqgAobinCRjjo5HvheLXU6A5Ls2sIfmU8XlnPaHv9uai2oPWGNCA 2Yo+KxscFNfx+7D5JTvgeR4ybhpnRvl+V8GRdS+xsa42T5RcB4hw8yvFoiwFzGTktg+T GtEHUiZNfFDJ5W4rDb9lgs1oe9J0pDNI9dER3iqWddFzyia1RvO6rdeZZdgpYN9AQnsu +ukA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=hDLhAH2zCEdvxzHmJuTOA8+eBl8yPc/xbStlAVgkLZM=; fh=X1/oBJvTGJUQ0YtRp03u+3tPfRw/dXXALWynfOSlfQQ=; b=X0Yg3ZV5F/ogoDNiNVW19aaLL0vfdwE0V4/BABgAybgu25W7B0BMS7SIuUAhbtaPVy GGJP0+IWUG25rc8Y9FQho/EERlgaDPOoymXcUUDzrkPrmDjkmZOS4RD8vJ0TCagc6nh5 oZwckcy7AOupRbD6NV12fkYZrlz9Mc/WvatHum4PyISf4JD/L5FEHY55xIAsZybxVe55 V6/up/+Z1xmCZZP97weKRsYs8h1uqev1uOm5qTxDeMLFs3fOgUELpbptUCcU765Ua1Ax avWG/5cEPl5nL3h6MHSV2BXlTr2/Hi/ZZs71YYWUjOPnzrjOkizbsFNsQA0vTv+j7/5V pj2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z7hFw9ac; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-90012-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90012-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bq13-20020a056a02044d00b005cfb2c44526si8420958pgb.862.2024.03.03.19.29.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 19:29:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90012-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z7hFw9ac; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-90012-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90012-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5FEC328147A for ; Mon, 4 Mar 2024 03:29:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA0356138; Mon, 4 Mar 2024 03:29:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z7hFw9ac" 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 BC3AF6116 for ; Mon, 4 Mar 2024 03:29:01 +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=1709522941; cv=none; b=G+AvkGLsnY6MyMz0zN9PHbGgmqdrR6rVmwG95UZc1q8KCn5lbkr+smbIpSZEaVQOhUYvUHdZAjoX262hPszwwKu192unAC9DDC6egn3B0ymRL1l6BFdq/v22OwfT9YOVW/isWdod1NfQJwpALaDCk5eHBGoJHRP39Lm+96ECApU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709522941; c=relaxed/simple; bh=8cuxxMKaThdnE9KmCstvXojMSrmD62OoxAVhmApiYKE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=UrLM+A8opCltdOy+FPUbQ0gTSu7s8cJhSlBFhBLnoyDZOtpF4Fi8cmLo+il+FQdx1cbt9qd8tKT/OznyUeLA6bONUcFyJTdQmfnzpye4ok3gGN66KNjhD9Q1MyLXPsX6mHZSOD6Mg6tapEA0+onjdDn/fx5B3Hmebgh5v5YBr68= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z7hFw9ac; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DDE5C433F1; Mon, 4 Mar 2024 03:28:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709522941; bh=8cuxxMKaThdnE9KmCstvXojMSrmD62OoxAVhmApiYKE=; h=From:To:Cc:Subject:Date:From; b=Z7hFw9ac0QSFPKRPuoRgzB/oArpB9Hrop4kMsYGmW7xiT5GWIL4uMBYEUCl6qmFCM L9Dscl48ekyWVlvKKmm1fV8ydfr02lNEl8U2d2cuMn/4ymURa7rS/v/3a0SEbI9+8G KD4DkWQbuvB03uehQK/xGVCLIfQe0M7Vddx00WWekNOI/gZLcBQZfOfo6cUBciZXcg ksG9piS6GtMV98eAqbIMe8rbHLI+wropzQ0bVarXIhhIQ5LxQnbI4epeL53WniXtPK p2CJ+wCx/cH8gi5PMJo2INWLy1XXfqgvgCzYoOsfI+UBqwIYSDskkK5hyOt5vnQQVX 337JPVahscn1g== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v2] f2fs: introduce SEGS_TO_BLKS/BLKS_TO_SEGS for cleanup Date: Mon, 4 Mar 2024 11:28:55 +0800 Message-Id: <20240304032855.1425579-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Just cleanup, no functional change. Signed-off-by: Chao Yu --- v2: - don't cast type of segment number from unsigned int to long long, because segs << log_blocks_per_seg won't overflow due to f2fs doesn't support 64-bits addressing. fs/f2fs/debug.c | 7 +++---- fs/f2fs/f2fs.h | 14 ++++++++------ fs/f2fs/gc.c | 10 +++++----- fs/f2fs/gc.h | 4 ++-- fs/f2fs/segment.c | 12 ++++++------ fs/f2fs/segment.h | 15 +++++++-------- fs/f2fs/super.c | 16 ++++++++-------- fs/f2fs/sysfs.c | 4 ++-- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index 0d02224b99b7..8b0e1e71b667 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c @@ -135,7 +135,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) si->cur_ckpt_time = sbi->cprc_info.cur_time; si->peak_ckpt_time = sbi->cprc_info.peak_time; spin_unlock(&sbi->cprc_info.stat_lock); - si->total_count = (int)sbi->user_block_count / BLKS_PER_SEG(sbi); + si->total_count = BLKS_TO_SEGS(sbi, (int)sbi->user_block_count); si->rsvd_segs = reserved_segments(sbi); si->overp_segs = overprovision_segments(sbi); si->valid_count = valid_user_blocks(sbi); @@ -176,11 +176,10 @@ static void update_general_status(struct f2fs_sb_info *sbi) si->alloc_nids = NM_I(sbi)->nid_cnt[PREALLOC_NID]; si->io_skip_bggc = sbi->io_skip_bggc; si->other_skip_bggc = sbi->other_skip_bggc; - si->util_free = (int)(free_user_blocks(sbi) >> sbi->log_blocks_per_seg) + si->util_free = (int)(BLKS_TO_SEGS(sbi, free_user_blocks(sbi))) * 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg) / 2; - si->util_valid = (int)(written_block_count(sbi) >> - sbi->log_blocks_per_seg) + si->util_valid = (int)(BLKS_TO_SEGS(sbi, written_block_count(sbi))) * 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg) / 2; si->util_invalid = 50 - si->util_free - si->util_valid; diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index db05fd02350a..33fd02716cf3 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1815,12 +1815,14 @@ struct f2fs_sb_info { }; /* Definitions to access f2fs_sb_info */ -#define BLKS_PER_SEG(sbi) \ - ((sbi)->blocks_per_seg) -#define BLKS_PER_SEC(sbi) \ - ((sbi)->segs_per_sec << (sbi)->log_blocks_per_seg) -#define SEGS_PER_SEC(sbi) \ - ((sbi)->segs_per_sec) +#define SEGS_TO_BLKS(sbi, segs) \ + ((segs) << (sbi)->log_blocks_per_seg) +#define BLKS_TO_SEGS(sbi, blks) \ + ((blks) >> (sbi)->log_blocks_per_seg) + +#define BLKS_PER_SEG(sbi) ((sbi)->blocks_per_seg) +#define BLKS_PER_SEC(sbi) (SEGS_TO_BLKS(sbi, (sbi)->segs_per_sec)) +#define SEGS_PER_SEC(sbi) ((sbi)->segs_per_sec) __printf(3, 4) void f2fs_printk(struct f2fs_sb_info *sbi, bool limit_rate, const char *fmt, ...); diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index e435e1f58cd5..3898b22b07ea 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -301,7 +301,7 @@ static unsigned int get_max_cost(struct f2fs_sb_info *sbi, /* LFS */ if (p->gc_mode == GC_GREEDY) - return 2 * BLKS_PER_SEG(sbi) * p->ofs_unit; + return SEGS_TO_BLKS(sbi, 2 * p->ofs_unit); else if (p->gc_mode == GC_CB) return UINT_MAX; else if (p->gc_mode == GC_AT) @@ -348,7 +348,7 @@ static unsigned int get_cb_cost(struct f2fs_sb_info *sbi, unsigned int segno) mtime = div_u64(mtime, usable_segs_per_sec); vblocks = div_u64(vblocks, usable_segs_per_sec); - u = (vblocks * 100) >> sbi->log_blocks_per_seg; + u = BLKS_TO_SEGS(sbi, vblocks * 100); /* Handle if the system time has changed by the user */ if (mtime < sit_i->min_mtime) @@ -2078,7 +2078,7 @@ static void update_sb_metadata(struct f2fs_sb_info *sbi, int secs) raw_sb->segment_count = cpu_to_le32(segment_count + segs); raw_sb->segment_count_main = cpu_to_le32(segment_count_main + segs); raw_sb->block_count = cpu_to_le64(block_count + - (long long)(segs << sbi->log_blocks_per_seg)); + (long long)SEGS_TO_BLKS(sbi, segs)); if (f2fs_is_multi_device(sbi)) { int last_dev = sbi->s_ndevs - 1; int dev_segs = @@ -2094,7 +2094,7 @@ static void update_sb_metadata(struct f2fs_sb_info *sbi, int secs) static void update_fs_metadata(struct f2fs_sb_info *sbi, int secs) { int segs = secs * SEGS_PER_SEC(sbi); - long long blks = (long long)segs << sbi->log_blocks_per_seg; + long long blks = SEGS_TO_BLKS(sbi, segs); long long user_block_count = le64_to_cpu(F2FS_CKPT(sbi)->user_block_count); @@ -2136,7 +2136,7 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count) int last_dev = sbi->s_ndevs - 1; __u64 last_segs = FDEV(last_dev).total_segments; - if (block_count + (last_segs << sbi->log_blocks_per_seg) <= + if (block_count + SEGS_TO_BLKS(sbi, last_segs) <= old_block_count) return -EINVAL; } diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h index 28a00942802c..9c0d06c4d19a 100644 --- a/fs/f2fs/gc.h +++ b/fs/f2fs/gc.h @@ -96,7 +96,7 @@ static inline block_t free_segs_blk_count(struct f2fs_sb_info *sbi) if (f2fs_sb_has_blkzoned(sbi)) return free_segs_blk_count_zoned(sbi); - return free_segments(sbi) << sbi->log_blocks_per_seg; + return SEGS_TO_BLKS(sbi, free_segments(sbi)); } static inline block_t free_user_blocks(struct f2fs_sb_info *sbi) @@ -104,7 +104,7 @@ static inline block_t free_user_blocks(struct f2fs_sb_info *sbi) block_t free_blks, ovp_blks; free_blks = free_segs_blk_count(sbi); - ovp_blks = overprovision_segments(sbi) << sbi->log_blocks_per_seg; + ovp_blks = SEGS_TO_BLKS(sbi, overprovision_segments(sbi)); if (free_blks < ovp_blks) return 0; diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index d50f007d0e86..22241aba6564 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -451,8 +451,8 @@ static inline bool excess_dirty_threshold(struct f2fs_sb_info *sbi) unsigned int nodes = get_pages(sbi, F2FS_DIRTY_NODES); unsigned int meta = get_pages(sbi, F2FS_DIRTY_META); unsigned int imeta = get_pages(sbi, F2FS_DIRTY_IMETA); - unsigned int threshold = (factor * DEFAULT_DIRTY_THRESHOLD) << - sbi->log_blocks_per_seg; + unsigned int threshold = + SEGS_TO_BLKS(sbi, (factor * DEFAULT_DIRTY_THRESHOLD)); unsigned int global_threshold = threshold * 3 / 2; if (dents >= threshold || qdata >= threshold || @@ -875,7 +875,7 @@ block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi) { int ovp_hole_segs = (overprovision_segments(sbi) - reserved_segments(sbi)); - block_t ovp_holes = ovp_hole_segs << sbi->log_blocks_per_seg; + block_t ovp_holes = SEGS_TO_BLKS(sbi, ovp_hole_segs); struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); block_t holes[2] = {0, 0}; /* DATA and NODE */ block_t unusable; @@ -2188,7 +2188,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, if (!f2fs_sb_has_blkzoned(sbi) && (!f2fs_lfs_mode(sbi) || !__is_large_section(sbi))) { f2fs_issue_discard(sbi, START_BLOCK(sbi, start), - (end - start) << sbi->log_blocks_per_seg); + SEGS_TO_BLKS(sbi, end - start)); continue; } next: @@ -2305,7 +2305,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi) atomic_set(&dcc->queued_discard, 0); atomic_set(&dcc->discard_cmd_cnt, 0); dcc->nr_discards = 0; - dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; + dcc->max_discards = SEGS_TO_BLKS(sbi, MAIN_SEGS(sbi)); dcc->max_discard_request = DEF_MAX_DISCARD_REQUEST; dcc->min_discard_issue_time = DEF_MIN_DISCARD_ISSUE_TIME; dcc->mid_discard_issue_time = DEF_MID_DISCARD_ISSUE_TIME; @@ -4541,7 +4541,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi) #endif sit_i->sit_base_addr = le32_to_cpu(raw_super->sit_blkaddr); - sit_i->sit_blocks = sit_segs << sbi->log_blocks_per_seg; + sit_i->sit_blocks = SEGS_TO_BLKS(sbi, sit_segs); sit_i->written_valid_blocks = 0; sit_i->bitmap_size = sit_bitmap_size; sit_i->dirty_sentries = 0; diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 4595f1cc0382..e1c0f418aa11 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -77,21 +77,21 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi, #define TOTAL_SEGS(sbi) \ (SM_I(sbi) ? SM_I(sbi)->segment_count : \ le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count)) -#define TOTAL_BLKS(sbi) (TOTAL_SEGS(sbi) << (sbi)->log_blocks_per_seg) +#define TOTAL_BLKS(sbi) (SEGS_TO_BLKS(sbi, TOTAL_SEGS(sbi))) #define MAX_BLKADDR(sbi) (SEG0_BLKADDR(sbi) + TOTAL_BLKS(sbi)) #define SEGMENT_SIZE(sbi) (1ULL << ((sbi)->log_blocksize + \ (sbi)->log_blocks_per_seg)) #define START_BLOCK(sbi, segno) (SEG0_BLKADDR(sbi) + \ - (GET_R2L_SEGNO(FREE_I(sbi), segno) << (sbi)->log_blocks_per_seg)) + (SEGS_TO_BLKS(sbi, GET_R2L_SEGNO(FREE_I(sbi), segno)))) #define NEXT_FREE_BLKADDR(sbi, curseg) \ (START_BLOCK(sbi, (curseg)->segno) + (curseg)->next_blkoff) #define GET_SEGOFF_FROM_SEG0(sbi, blk_addr) ((blk_addr) - SEG0_BLKADDR(sbi)) #define GET_SEGNO_FROM_SEG0(sbi, blk_addr) \ - (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) >> (sbi)->log_blocks_per_seg) + (BLKS_TO_SEGS(sbi, GET_SEGOFF_FROM_SEG0(sbi, blk_addr))) #define GET_BLKOFF_FROM_SEG0(sbi, blk_addr) \ (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) & (BLKS_PER_SEG(sbi) - 1)) @@ -100,11 +100,10 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi, NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi), \ GET_SEGNO_FROM_SEG0(sbi, blk_addr))) #define CAP_BLKS_PER_SEC(sbi) \ - (SEGS_PER_SEC(sbi) * BLKS_PER_SEG(sbi) - \ - (sbi)->unusable_blocks_per_sec) + (BLKS_PER_SEC(sbi) - (sbi)->unusable_blocks_per_sec) #define CAP_SEGS_PER_SEC(sbi) \ - (SEGS_PER_SEC(sbi) - ((sbi)->unusable_blocks_per_sec >> \ - (sbi)->log_blocks_per_seg)) + (SEGS_PER_SEC(sbi) - \ + BLKS_TO_SEGS(sbi, (sbi)->unusable_blocks_per_sec)) #define GET_SEC_FROM_SEG(sbi, segno) \ (((segno) == -1) ? -1 : (segno) / SEGS_PER_SEC(sbi)) #define GET_SEG_FROM_SEC(sbi, secno) \ @@ -904,7 +903,7 @@ static inline int nr_pages_to_skip(struct f2fs_sb_info *sbi, int type) if (type == DATA) return BLKS_PER_SEG(sbi); else if (type == NODE) - return 8 * BLKS_PER_SEG(sbi); + return SEGS_TO_BLKS(sbi, 8); else if (type == META) return 8 * BIO_MAX_VECS; else diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index b038028cff27..78a76583a4aa 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3756,9 +3756,9 @@ static void init_sb_info(struct f2fs_sb_info *sbi) sbi->segs_per_sec = le32_to_cpu(raw_super->segs_per_sec); sbi->secs_per_zone = le32_to_cpu(raw_super->secs_per_zone); sbi->total_sections = le32_to_cpu(raw_super->section_count); - sbi->total_node_count = - ((le32_to_cpu(raw_super->segment_count_nat) / 2) * - NAT_ENTRY_PER_BLOCK) << sbi->log_blocks_per_seg; + sbi->total_node_count = SEGS_TO_BLKS(sbi, + ((le32_to_cpu(raw_super->segment_count_nat) / 2) * + NAT_ENTRY_PER_BLOCK)); F2FS_ROOT_INO(sbi) = le32_to_cpu(raw_super->root_ino); F2FS_NODE_INO(sbi) = le32_to_cpu(raw_super->node_ino); F2FS_META_INO(sbi) = le32_to_cpu(raw_super->meta_ino); @@ -4200,14 +4200,14 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) if (i == 0) { FDEV(i).start_blk = 0; FDEV(i).end_blk = FDEV(i).start_blk + - (FDEV(i).total_segments << - sbi->log_blocks_per_seg) - 1 + - le32_to_cpu(raw_super->segment0_blkaddr); + SEGS_TO_BLKS(sbi, + FDEV(i).total_segments) - 1 + + le32_to_cpu(raw_super->segment0_blkaddr); } else { FDEV(i).start_blk = FDEV(i - 1).end_blk + 1; FDEV(i).end_blk = FDEV(i).start_blk + - (FDEV(i).total_segments << - sbi->log_blocks_per_seg) - 1; + SEGS_TO_BLKS(sbi, + FDEV(i).total_segments) - 1; FDEV(i).bdev_handle = bdev_open_by_path( FDEV(i).path, mode, sbi->sb, NULL); } diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 906d2af2d849..10f308b3128f 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -493,8 +493,8 @@ static ssize_t __sbi_store(struct f2fs_attr *a, spin_lock(&sbi->stat_lock); if (t > (unsigned long)(sbi->user_block_count - F2FS_OPTION(sbi).root_reserved_blocks - - (SM_I(sbi)->additional_reserved_segments << - sbi->log_blocks_per_seg))) { + SEGS_TO_BLKS(sbi, + SM_I(sbi)->additional_reserved_segments))) { spin_unlock(&sbi->stat_lock); return -EINVAL; } -- 2.40.1