From patchwork Fri Oct 21 16:51:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 6871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp803571wrr; Fri, 21 Oct 2022 09:58:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4XKeGKlOz85B3s61vSt+NYLCJOrF4OV4YKMguhpJb7Ijlzv67QBv96umwFPUwINAQwK9wj X-Received: by 2002:a05:6402:4441:b0:454:8a74:5459 with SMTP id o1-20020a056402444100b004548a745459mr17921559edb.155.1666371491539; Fri, 21 Oct 2022 09:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666371491; cv=none; d=google.com; s=arc-20160816; b=xx7PaONH7iN+iz8UHbsXtjqmlEdZ7vmCseS9mAT8xAkWWaT9BCX/rDBBSDL3tpPSPe H1BWF2gLDs6A1Bz/KaJtRbMo4H/SDGIkwWmKCWwqkImfNxcbUfB0vxMp9EUfpRkP8cEQ eANuO4J2bs5a9n5BAtAts/jECWEPtYHwHyvSjQqpgM2exLC9+TVQVWxH2p7aYTAIKQNy zH2uVHbCirsqL9a/DeNa18i/bLd30mAge3wY73k/P5nXZb3n1inxPx7nVkKq16g7DPi9 iXwSkold9Tl/Lxbbnj//mJBjBYVB4CsX1eIUHuh1qQQjTZzpRx6VZzVxLPhgBC7FtTCR K/iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=zrg3GA4EWJkT/4Al6TICZypL9gmnHRpNe4mgRyK9fUo=; b=tWgamtsi91HYKwEScHmgz4Qqs9UdV5N/7/zkBKBwoEas/EIbwyP9TGJfOVhRU6h++g cQ3v7HZfC7f206RdJ91i8zCIjf9szY9xHuxsPMDceIoGR0I1G9u3YRj+wPb75IN108vf yQmZX7RabPpM5Af56bC6DibYXfJ6TWjrWpPYnuTvFdjpwNwMjRsRPE2RPe5/v6xoFNGT XhjAG+Pgx4cn+wsw15B5eYnL5SENFl3DQlYlh0/1/9ljuKByobpu8G7xvGkHbfqVt84P 6dRH4vPfUpScNccpYhsHWD+wfgsIdZ+XfX/sxH56/W9geZW/mFdtu1VSnax5MqZVVn3Z sLjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=aOjSHUzA; dkim=pass header.i=@paragon-software.com header.s=mail header.b=MgV6RxC3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v11-20020a50d08b000000b0045903f0af98si19940005edd.128.2022.10.21.09.57.46; Fri, 21 Oct 2022 09:58:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=aOjSHUzA; dkim=pass header.i=@paragon-software.com header.s=mail header.b=MgV6RxC3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230474AbiJUQvt (ORCPT + 99 others); Fri, 21 Oct 2022 12:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbiJUQvg (ORCPT ); Fri, 21 Oct 2022 12:51:36 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9E5B273563; Fri, 21 Oct 2022 09:51:34 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id BE0912201; Fri, 21 Oct 2022 16:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1666370939; bh=zrg3GA4EWJkT/4Al6TICZypL9gmnHRpNe4mgRyK9fUo=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=aOjSHUzAkDwdCST/J5WWCr24gTbPuRdK6DdDWzqIxU3Ao1aGYxQ7aVE+GiywCQFxU d02EXm7PvSlrwKBYzB1gW7Zna55p1l+cvTXodQTsZKMWYBvy3VeaOnTc4iJcotuqNg V71RtJgUOb3pQh9SLesdZ1EsFf6vr0OHlKCF3AN4= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id C4B102138; Fri, 21 Oct 2022 16:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1666371092; bh=zrg3GA4EWJkT/4Al6TICZypL9gmnHRpNe4mgRyK9fUo=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=MgV6RxC3lYeFhnD0Z7L8hWVnn/1X6siCAPIlQ8kCRol/+z8E0EtVsjaFMFtCdJodv Q2PYE44EasMmmc0iMmNsx2KsVQF7pP9OnLg0atWG2cu1h0hIyhC7YUbbEDCPxmlFGe IQahmx8FwSSVG1oP1/uNJwm4zFFejIAGgCBLbzok= Received: from [172.30.8.65] (172.30.8.65) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Fri, 21 Oct 2022 19:51:32 +0300 Message-ID: Date: Fri, 21 Oct 2022 19:51:32 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [PATCH 1/4] fs/ntfs3: Add ntfs_bitmap_weight_le function and refactoring Content-Language: en-US From: Konstantin Komarov To: CC: , References: <9a7d08c2-e503-ac1d-1621-20369c073530@paragon-software.com> In-Reply-To: <9a7d08c2-e503-ac1d-1621-20369c073530@paragon-software.com> X-Originating-IP: [172.30.8.65] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747317153366094723?= X-GMAIL-MSGID: =?utf-8?q?1747317153366094723?= Added ntfs_bitmap_weight_le function. Changed argument types of bits/bitmap functions. Signed-off-by: Konstantin Komarov --- fs/ntfs3/bitfunc.c | 4 +- fs/ntfs3/bitmap.c | 100 +++++++++++++++++++++++++-------------------- fs/ntfs3/ntfs_fs.h | 11 ++--- 3 files changed, 63 insertions(+), 52 deletions(-) diff --git a/fs/ntfs3/bitfunc.c b/fs/ntfs3/bitfunc.c index 50d838093790..25a4d4896aa9 100644 --- a/fs/ntfs3/bitfunc.c +++ b/fs/ntfs3/bitfunc.c @@ -30,7 +30,7 @@ static const u8 zero_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, * * Return: True if all bits [bit, bit+nbits) are zeros "0". */ -bool are_bits_clear(const ulong *lmap, size_t bit, size_t nbits) +bool are_bits_clear(const void *lmap, size_t bit, size_t nbits) { size_t pos = bit & 7; const u8 *map = (u8 *)lmap + (bit >> 3); @@ -78,7 +78,7 @@ bool are_bits_clear(const ulong *lmap, size_t bit, size_t nbits) * * Return: True if all bits [bit, bit+nbits) are ones "1". */ -bool are_bits_set(const ulong *lmap, size_t bit, size_t nbits) +bool are_bits_set(const void *lmap, size_t bit, size_t nbits) { u8 mask; size_t pos = bit & 7; diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c index 899a631863c8..6e68887597ac 100644 --- a/fs/ntfs3/bitmap.c +++ b/fs/ntfs3/bitmap.c @@ -59,7 +59,7 @@ void ntfs3_exit_bitmap(void) * * Return: -1 if not found. */ -static size_t wnd_scan(const ulong *buf, size_t wbit, u32 wpos, u32 wend, +static size_t wnd_scan(const void *buf, size_t wbit, u32 wpos, u32 wend, size_t to_alloc, size_t *prev_tail, size_t *b_pos, size_t *b_len) { @@ -504,7 +504,6 @@ static int wnd_rescan(struct wnd_bitmap *wnd) u8 cluster_bits = sbi->cluster_bits; u32 wbits = 8 * sb->s_blocksize; u32 used, frb; - const ulong *buf; size_t wpos, wbit, iw, vbo; struct buffer_head *bh = NULL; CLST lcn, clen; @@ -558,9 +557,7 @@ static int wnd_rescan(struct wnd_bitmap *wnd) goto out; } - buf = (ulong *)bh->b_data; - - used = __bitmap_weight(buf, wbits); + used = ntfs_bitmap_weight_le(bh->b_data, wbits); if (used < wbits) { frb = wbits - used; wnd->free_bits[iw] = frb; @@ -574,7 +571,7 @@ static int wnd_rescan(struct wnd_bitmap *wnd) wbits = wnd->nbits - wbit; do { - used = find_next_zero_bit_le(buf, wbits, wpos); + used = find_next_zero_bit_le(bh->b_data, wbits, wpos); if (used > wpos && prev_tail) { wnd_add_free_ext(wnd, wbit + wpos - prev_tail, @@ -590,7 +587,7 @@ static int wnd_rescan(struct wnd_bitmap *wnd) break; } - frb = find_next_bit_le(buf, wbits, wpos); + frb = find_next_bit_le(bh->b_data, wbits, wpos); if (frb >= wbits) { /* Keep last free block. */ prev_tail += frb - wpos; @@ -718,7 +715,6 @@ int wnd_set_free(struct wnd_bitmap *wnd, size_t bit, size_t bits) while (iw < wnd->nwnd && bits) { u32 tail, op; - ulong *buf; if (iw + 1 == wnd->nwnd) wbits = wnd->bits_last; @@ -732,11 +728,9 @@ int wnd_set_free(struct wnd_bitmap *wnd, size_t bit, size_t bits) break; } - buf = (ulong *)bh->b_data; - lock_buffer(bh); - ntfs_bitmap_clear_le(buf, wbit, op); + ntfs_bitmap_clear_le(bh->b_data, wbit, op); wnd->free_bits[iw] += op; @@ -771,7 +765,6 @@ int wnd_set_used(struct wnd_bitmap *wnd, size_t bit, size_t bits) while (iw < wnd->nwnd && bits) { u32 tail, op; - ulong *buf; if (unlikely(iw + 1 == wnd->nwnd)) wbits = wnd->bits_last; @@ -784,11 +777,10 @@ int wnd_set_used(struct wnd_bitmap *wnd, size_t bit, size_t bits) err = PTR_ERR(bh); break; } - buf = (ulong *)bh->b_data; lock_buffer(bh); - ntfs_bitmap_set_le(buf, wbit, op); + ntfs_bitmap_set_le(bh->b_data, wbit, op); wnd->free_bits[iw] -= op; set_buffer_uptodate(bh); @@ -836,7 +828,7 @@ static bool wnd_is_free_hlp(struct wnd_bitmap *wnd, size_t bit, size_t bits) if (IS_ERR(bh)) return false; - ret = are_bits_clear((ulong *)bh->b_data, wbit, op); + ret = are_bits_clear(bh->b_data, wbit, op); put_bh(bh); if (!ret) @@ -928,7 +920,7 @@ bool wnd_is_used(struct wnd_bitmap *wnd, size_t bit, size_t bits) if (IS_ERR(bh)) goto out; - ret = are_bits_set((ulong *)bh->b_data, wbit, op); + ret = are_bits_set(bh->b_data, wbit, op); put_bh(bh); if (!ret) goto out; @@ -959,7 +951,6 @@ size_t wnd_find(struct wnd_bitmap *wnd, size_t to_alloc, size_t hint, size_t fnd, max_alloc, b_len, b_pos; size_t iw, prev_tail, nwnd, wbit, ebit, zbit, zend; size_t to_alloc0 = to_alloc; - const ulong *buf; const struct e_node *e; const struct rb_node *pr, *cr; u8 log2_bits; @@ -1185,14 +1176,13 @@ size_t wnd_find(struct wnd_bitmap *wnd, size_t to_alloc, size_t hint, continue; } - buf = (ulong *)bh->b_data; - /* Scan range [wbit, zbit). */ if (wpos < wzbit) { /* Scan range [wpos, zbit). */ - fnd = wnd_scan(buf, wbit, wpos, wzbit, - to_alloc, &prev_tail, - &b_pos, &b_len); + fnd = wnd_scan(bh->b_data, wbit, wpos, + wzbit, to_alloc, + &prev_tail, &b_pos, + &b_len); if (fnd != MINUS_ONE_T) { put_bh(bh); goto found; @@ -1203,7 +1193,7 @@ size_t wnd_find(struct wnd_bitmap *wnd, size_t to_alloc, size_t hint, /* Scan range [zend, ebit). */ if (wzend < wbits) { - fnd = wnd_scan(buf, wbit, + fnd = wnd_scan(bh->b_data, wbit, max(wzend, wpos), wbits, to_alloc, &prev_tail, &b_pos, &b_len); @@ -1242,11 +1232,9 @@ size_t wnd_find(struct wnd_bitmap *wnd, size_t to_alloc, size_t hint, continue; } - buf = (ulong *)bh->b_data; - /* Scan range [wpos, eBits). */ - fnd = wnd_scan(buf, wbit, wpos, wbits, to_alloc, &prev_tail, - &b_pos, &b_len); + fnd = wnd_scan(bh->b_data, wbit, wpos, wbits, to_alloc, + &prev_tail, &b_pos, &b_len); put_bh(bh); if (fnd != MINUS_ONE_T) goto found; @@ -1344,7 +1332,6 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits) size_t frb; u64 vbo, lbo, bytes; struct buffer_head *bh; - ulong *buf; if (iw + 1 == new_wnd) wbits = new_last; @@ -1361,10 +1348,9 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits) return -EIO; lock_buffer(bh); - buf = (ulong *)bh->b_data; - ntfs_bitmap_clear_le(buf, b0, blocksize * 8 - b0); - frb = wbits - __bitmap_weight(buf, wbits); + ntfs_bitmap_clear_le(bh->b_data, b0, blocksize * 8 - b0); + frb = wbits - ntfs_bitmap_weight_le(bh->b_data, wbits); wnd->total_zeroes += frb - wnd->free_bits[iw]; wnd->free_bits[iw] = frb; @@ -1411,7 +1397,6 @@ int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range) CLST lcn_from = bytes_to_cluster(sbi, range->start); size_t iw = lcn_from >> (sb->s_blocksize_bits + 3); u32 wbit = lcn_from & (wbits - 1); - const ulong *buf; CLST lcn_to; if (!minlen) @@ -1446,10 +1431,8 @@ int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range) break; } - buf = (ulong *)bh->b_data; - for (; wbit < wbits; wbit++) { - if (!test_bit_le(wbit, buf)) { + if (!test_bit_le(wbit, bh->b_data)) { if (!len) lcn = lcn_wnd + wbit; len += 1; @@ -1482,42 +1465,69 @@ int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range) return err; } -void ntfs_bitmap_set_le(unsigned long *map, unsigned int start, int len) +#if BITS_PER_LONG == 64 +typedef __le64 bitmap_ulong; +#define cpu_to_ul(x) cpu_to_le64(x) +#define ul_to_cpu(x) le64_to_cpu(x) +#else +typedef __le32 bitmap_ulong; +#define cpu_to_ul(x) cpu_to_le32(x) +#define ul_to_cpu(x) le32_to_cpu(x) +#endif + +void ntfs_bitmap_set_le(void *map, unsigned int start, int len) { - unsigned long *p = map + BIT_WORD(start); + bitmap_ulong *p = (bitmap_ulong *)map + BIT_WORD(start); const unsigned int size = start + len; int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG); - unsigned long mask_to_set = cpu_to_le32(BITMAP_FIRST_WORD_MASK(start)); + bitmap_ulong mask_to_set = cpu_to_ul(BITMAP_FIRST_WORD_MASK(start)); while (len - bits_to_set >= 0) { *p |= mask_to_set; len -= bits_to_set; bits_to_set = BITS_PER_LONG; - mask_to_set = ~0UL; + mask_to_set = cpu_to_ul(~0UL); p++; } if (len) { - mask_to_set &= cpu_to_le32(BITMAP_LAST_WORD_MASK(size)); + mask_to_set &= cpu_to_ul(BITMAP_LAST_WORD_MASK(size)); *p |= mask_to_set; } } -void ntfs_bitmap_clear_le(unsigned long *map, unsigned int start, int len) +void ntfs_bitmap_clear_le(void *map, unsigned int start, int len) { - unsigned long *p = map + BIT_WORD(start); + bitmap_ulong *p = (bitmap_ulong *)map + BIT_WORD(start); const unsigned int size = start + len; int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG); - unsigned long mask_to_clear = cpu_to_le32(BITMAP_FIRST_WORD_MASK(start)); + bitmap_ulong mask_to_clear = cpu_to_ul(BITMAP_FIRST_WORD_MASK(start)); while (len - bits_to_clear >= 0) { *p &= ~mask_to_clear; len -= bits_to_clear; bits_to_clear = BITS_PER_LONG; - mask_to_clear = ~0UL; + mask_to_clear = cpu_to_ul(~0UL); p++; } if (len) { - mask_to_clear &= cpu_to_le32(BITMAP_LAST_WORD_MASK(size)); + mask_to_clear &= cpu_to_ul(BITMAP_LAST_WORD_MASK(size)); *p &= ~mask_to_clear; } } + +unsigned int ntfs_bitmap_weight_le(const void *bitmap, int bits) +{ + const ulong *bmp = bitmap; + unsigned int k, lim = bits / BITS_PER_LONG; + unsigned int w = 0; + + for (k = 0; k < lim; k++) + w += hweight_long(bmp[k]); + + if (bits % BITS_PER_LONG) { + w += hweight_long(ul_to_cpu(((bitmap_ulong *)bitmap)[k]) & + BITMAP_LAST_WORD_MASK(bits)); + } + + return w; +} diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index a71b4a0a66d8..2f6fb6ceaeca 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -471,9 +471,9 @@ static inline size_t al_aligned(size_t size) } /* Globals from bitfunc.c */ -bool are_bits_clear(const ulong *map, size_t bit, size_t nbits); -bool are_bits_set(const ulong *map, size_t bit, size_t nbits); -size_t get_set_bits_ex(const ulong *map, size_t bit, size_t nbits); +bool are_bits_clear(const void *map, size_t bit, size_t nbits); +bool are_bits_set(const void *map, size_t bit, size_t nbits); +size_t get_set_bits_ex(const void *map, size_t bit, size_t nbits); /* Globals from dir.c */ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len, @@ -837,8 +837,9 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits); void wnd_zone_set(struct wnd_bitmap *wnd, size_t Lcn, size_t Len); int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range); -void ntfs_bitmap_set_le(unsigned long *map, unsigned int start, int len); -void ntfs_bitmap_clear_le(unsigned long *map, unsigned int start, int len); +void ntfs_bitmap_set_le(void *map, unsigned int start, int len); +void ntfs_bitmap_clear_le(void *map, unsigned int start, int len); +unsigned int ntfs_bitmap_weight_le(const void *bitmap, int bits); /* Globals from upcase.c */ int ntfs_cmp_names(const __le16 *s1, size_t l1, const __le16 *s2, size_t l2, From patchwork Fri Oct 21 16:52:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 6872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp803591wrr; Fri, 21 Oct 2022 09:58:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yXOc6+R08tZWFGVo8BMytLp+HfY1xYZGLbzlcDiw7VPWPUxv7ah/N0UKHngFSOZBws5M8 X-Received: by 2002:a17:907:3d9e:b0:791:8933:f9fc with SMTP id he30-20020a1709073d9e00b007918933f9fcmr16592206ejc.111.1666371495346; Fri, 21 Oct 2022 09:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666371495; cv=none; d=google.com; s=arc-20160816; b=PDtKjck5b9VqNaIyW/Zq8jaJyyDqxq5sze2QyJlH5FKzsOD5MRWRlPiVgWZMjIuWHN F51oWYRi9YEH/R9YabY6tNK1xVFyD2sqlEbcnDp6lzTz3aDP9fL1OUTdSdyrfkGjxJAx hrVoYjfzvXl3BPbWl/6xvjcoEhFmk6GnrqsoXHlU6OY93MHsECTFgX9LeaSSYWg3CCsR YEFHKou0nwhQSLIaHf9tUqLL8/f637vdg8Avk+CWZT3SjbBuPQcMcZW/0m57R47qA1cb mbwoIOLoH2SJeCYHjudpCxmcebaVh4vmQzJOoa99rU7BoYJIYw9ZTYqkKSf7589JjMHw wRMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=ZCNllPC/IP07/I4v8msKmPt1Eyvxq647ljuvf/bKJqE=; b=U3DMbPyjaoR7esVZRltvP6yx6JZ+VEUeHO5JxtCaAEtkLWu1RXuaX9tQwM4G561nPe z7kjc07hAnbkjU/eAWMPqojO7fIeqtEQPlM7PBfk51VjOwAwpHt+AtrO0WCFYCR+pMkx 2Q5WO9owyRycCRvnn5msU73iQ8qQI9OrpNKKdlSsn4c30+i2FPwKNoR5cyWRIBnl1nZE ao49EYlvKchYnJO1antbssUv3Uxkijybi27QM9nXXnFEUanc3w6TuKR10VBVAbjY8B8a CIqzxpmFeFey+zOBUm1rYH7a//7uZ94V+hFGCeu8gl8920V75VJEt7/+vrqSOXHAzrhi iKrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=BCNrNY4S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa22-20020a1709076d1600b0078b96068bc0si22461627ejc.79.2022.10.21.09.57.50; Fri, 21 Oct 2022 09:58:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=BCNrNY4S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229908AbiJUQwL (ORCPT + 99 others); Fri, 21 Oct 2022 12:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbiJUQwF (ORCPT ); Fri, 21 Oct 2022 12:52:05 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1443628511B; Fri, 21 Oct 2022 09:52:03 -0700 (PDT) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 01ADA2201; Fri, 21 Oct 2022 16:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1666370969; bh=ZCNllPC/IP07/I4v8msKmPt1Eyvxq647ljuvf/bKJqE=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=BCNrNY4SZycSHjYIYtcSk/wdH/VOM2dKBRiLSxnClHBh58xSKhUY8mrLfMAGPcYoc O/3wJJsNoD+NQehqoADpq2Q7EACnrLf0QSRZOezV/fhpuxjGMyI5NJNOGtPmm66Orh 2Bodl6Ed1N/pn5CY1UD0pYXONoaX53RcN1f1xpnw= Received: from [172.30.8.65] (172.30.8.65) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Fri, 21 Oct 2022 19:52:01 +0300 Message-ID: <21a9d399-f3bf-6e57-0f38-cdbf68fdad58@paragon-software.com> Date: Fri, 21 Oct 2022 19:52:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [PATCH 2/4] fs/ntfs3: Fix sparse problems Content-Language: en-US From: Konstantin Komarov To: CC: , References: <9a7d08c2-e503-ac1d-1621-20369c073530@paragon-software.com> In-Reply-To: <9a7d08c2-e503-ac1d-1621-20369c073530@paragon-software.com> X-Originating-IP: [172.30.8.65] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747317156925541168?= X-GMAIL-MSGID: =?utf-8?q?1747317156925541168?= Fixing various problems, detected by sparse. Signed-off-by: Konstantin Komarov --- fs/ntfs3/attrib.c | 7 ++++--- fs/ntfs3/dir.c | 4 ++-- fs/ntfs3/frecord.c | 3 +-- fs/ntfs3/namei.c | 13 ++++++------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 63169529b52c..b2f54fab4001 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -2308,7 +2308,8 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes) if (!attr_b->non_res) { /* Still resident. */ - char *data = Add2Ptr(attr_b, attr_b->res.data_off); + char *data = Add2Ptr(attr_b, + le16_to_cpu(attr_b->res.data_off)); memmove(data + bytes, data, bytes); memset(data, 0, bytes); @@ -2400,8 +2401,8 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes) if (vbo <= ni->i_valid) ni->i_valid += bytes; - attr_b->nres.data_size = le64_to_cpu(data_size + bytes); - attr_b->nres.alloc_size = le64_to_cpu(alloc_size + bytes); + attr_b->nres.data_size = cpu_to_le64(data_size + bytes); + attr_b->nres.alloc_size = cpu_to_le64(alloc_size + bytes); /* ni->valid may be not equal valid_size (temporary). */ if (ni->i_valid > data_size + bytes) diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index fb438d604040..063a6654199b 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -26,8 +26,8 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len, if (!nls) { /* UTF-16 -> UTF-8 */ - ret = utf16s_to_utf8s(name, len, UTF16_LITTLE_ENDIAN, buf, - buf_len); + ret = utf16s_to_utf8s((wchar_t *)name, len, UTF16_LITTLE_ENDIAN, + buf, buf_len); buf[ret] = '\0'; return ret; } diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 8a741706c7a5..a7aed31e7c93 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -1670,8 +1670,7 @@ struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni, goto next; fns = (struct le_str *)&fname->name_len; - if (ntfs_cmp_names(uni->name, uni->len, fns->name, fns->len, NULL, - false)) + if (ntfs_cmp_names_cpu(uni, fns, NULL, false)) goto next; return fname; diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index 315763eb05ff..ff76389475ad 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -427,7 +427,8 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1, unsigned int len2 = name->len; unsigned int lm = min(len1, len2); unsigned char c1, c2; - struct cpu_str *uni1, *uni2; + struct cpu_str *uni1; + struct le_str *uni2; /* First try fast implementation. */ for (;;) { @@ -468,8 +469,9 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1, uni2 = Add2Ptr(uni1, 2048); - ret = ntfs_nls_to_utf16(sbi, name->name, name->len, uni2, NTFS_NAME_LEN, - UTF16_HOST_ENDIAN); + ret = ntfs_nls_to_utf16(sbi, name->name, name->len, + (struct cpu_str *)uni2, NTFS_NAME_LEN, + UTF16_LITTLE_ENDIAN); if (ret < 0) goto out; @@ -478,10 +480,7 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1, goto out; } - ret = !ntfs_cmp_names(uni1->name, uni1->len, uni2->name, uni2->len, - sbi->upcase, false) - ? 0 - : 1; + ret = !ntfs_cmp_names_cpu(uni1, uni2, sbi->upcase, false) ? 0 : 1; out: __putname(uni1); From patchwork Fri Oct 21 16:52:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 6873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp803978wrr; Fri, 21 Oct 2022 09:59:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5aPWAuwoFao9GMKi4m93OhdSVw+D8qy96cwacigSUw/OpFt0sUCq8d4y+9CfnOtZRVGNwz X-Received: by 2002:a17:907:97d4:b0:78e:1b8f:5767 with SMTP id js20-20020a17090797d400b0078e1b8f5767mr16595115ejc.473.1666371549140; Fri, 21 Oct 2022 09:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666371549; cv=none; d=google.com; s=arc-20160816; b=kEXSG1so4VzGDXEW7L8SCSXT6vPpItHtcEn5KWgCCUf/txpYe3UUlHW2L9hY0PXCP3 XlBqLDpDpW8eIIEKqGsyJGsGHYPlRRGb5UlY9aXTaIXk67ZR3nKXYjdHu5S5q9LmwKeg +V8DsgLtkfBVlFI5IFixNuqXl0/vE08GV0Q3gK3U2aq96SXC9tdiS5hFn0pgSF10PU82 GyiEGJreAC6Nq5aKoS3RBqwmeKEGK6BU8LlrKjEHTLNqd8N2/QPaVguQbHFDQmcMWbwQ x2SmxGLXKCWIN3zMLaJZJdeSmXSsZZtu0semX07ucy7yMbZK0vJqsQmO0BKb8tlTeFYj 3zxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=ruk+lQ8qKBUjR2PcFFn3GTmQ4eFByEiHHGss+6fUTZ8=; b=T4NcQQZq0AS+Fp9Xez9zpIWW3p4UG1IeaE09g7JGDJn5/+Rgy27B6KKhEC6/i70Z2j yBGp77Lla0j4rtS6aDyyLN7ZS6g3gTB+5yoZg49BMTHmENacMlkiv4AtWKFOm31RXB1p 0KYxl7us7/1VhveIVY8o+PyR5G/GxiyjKp0FnYcTpBQu5us2adNhshh2Z4+f+oqiO7EE yzWEnmqZ6PV3mElhsDaBxZ8XvXOidtNFAkobevJ3ozlx2tjqPidF9eJ/SrZj9ADCH/Pt r4VN1b4ru9Lg+ah1kqzKsXBaswtoeNauw0mg1nc/J8Q7fJWcSN4gg8tbP6jO+moMggV+ EOAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=RYcHTwaY; dkim=pass header.i=@paragon-software.com header.s=mail header.b=Xnxxfd7d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd42-20020a1709076e2a00b0077ccad52420si20875159ejc.275.2022.10.21.09.58.43; Fri, 21 Oct 2022 09:59:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=RYcHTwaY; dkim=pass header.i=@paragon-software.com header.s=mail header.b=Xnxxfd7d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229707AbiJUQwm (ORCPT + 99 others); Fri, 21 Oct 2022 12:52:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230475AbiJUQwj (ORCPT ); Fri, 21 Oct 2022 12:52:39 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC4E328C31E; Fri, 21 Oct 2022 09:52:34 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id BACA52201; Fri, 21 Oct 2022 16:49:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1666370998; bh=ruk+lQ8qKBUjR2PcFFn3GTmQ4eFByEiHHGss+6fUTZ8=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=RYcHTwaYadig9g3dq3DE/EsAuj8ufRfIUeOp9DmUzmeisYwyaDIZeYeS8cjEWXfMp cnwgQFaFyUo8OzUwZI5dhaUfAbzs4o3dW5pVmTZO0f1QTO5h581+Dd5sRwOpcJHbK0 huOHLkKGmHrHW/4abEtAM6FVOaFbAnqxFFy8btzE= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id C17262138; Fri, 21 Oct 2022 16:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1666371151; bh=ruk+lQ8qKBUjR2PcFFn3GTmQ4eFByEiHHGss+6fUTZ8=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=Xnxxfd7dZjye45gfV7Eow7bKYgGbxFUQimrS7c1L53CnajVIauM7nsi/yMzxiWO7Y 6Li0EzTF7CVc/hq4AXbxV4ttSLsud9MRCydq3dFbYaCeB7xUhk9RQwYuyhvZzu8rk8 jFsofz73zfGWwYXHKmlrGBPUl+0zg4l3OhO0G0fw= Received: from [172.30.8.65] (172.30.8.65) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Fri, 21 Oct 2022 19:52:31 +0300 Message-ID: <53145791-effe-ed2a-09f0-db042a6a9f5e@paragon-software.com> Date: Fri, 21 Oct 2022 19:52:31 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [PATCH 3/4] fs/ntfs3: Remove unused functions Content-Language: en-US From: Konstantin Komarov To: CC: , References: <9a7d08c2-e503-ac1d-1621-20369c073530@paragon-software.com> In-Reply-To: <9a7d08c2-e503-ac1d-1621-20369c073530@paragon-software.com> X-Originating-IP: [172.30.8.65] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747317213544212987?= X-GMAIL-MSGID: =?utf-8?q?1747317213544212987?= Removed attr_must_be_resident and ntfs_query_def. Signed-off-by: Konstantin Komarov --- fs/ntfs3/attrib.c | 27 --------------------------- fs/ntfs3/fsntfs.c | 29 ----------------------------- fs/ntfs3/ntfs_fs.h | 2 -- 3 files changed, 58 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index b2f54fab4001..7c00656151fb 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -54,33 +54,6 @@ static inline u64 get_pre_allocated(u64 size) return ret; } -/* - * attr_must_be_resident - * - * Return: True if attribute must be resident. - */ -static inline bool attr_must_be_resident(struct ntfs_sb_info *sbi, - enum ATTR_TYPE type) -{ - const struct ATTR_DEF_ENTRY *de; - - switch (type) { - case ATTR_STD: - case ATTR_NAME: - case ATTR_ID: - case ATTR_LABEL: - case ATTR_VOL_INFO: - case ATTR_ROOT: - case ATTR_EA_INFO: - return true; - default: - de = ntfs_query_def(sbi, type); - if (de && (de->flags & NTFS_ATTR_MUST_BE_RESIDENT)) - return true; - return false; - } -} - /* * attr_load_runs - Load all runs stored in @attr. */ diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 29e55fddf4e0..99dc2a287eab 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -321,35 +321,6 @@ int ntfs_loadlog_and_replay(struct ntfs_inode *ni, struct ntfs_sb_info *sbi) return err; } -/* - * ntfs_query_def - * - * Return: Current ATTR_DEF_ENTRY for given attribute type. - */ -const struct ATTR_DEF_ENTRY *ntfs_query_def(struct ntfs_sb_info *sbi, - enum ATTR_TYPE type) -{ - int type_in = le32_to_cpu(type); - size_t min_idx = 0; - size_t max_idx = sbi->def_entries - 1; - - while (min_idx <= max_idx) { - size_t i = min_idx + ((max_idx - min_idx) >> 1); - const struct ATTR_DEF_ENTRY *entry = sbi->def_table + i; - int diff = le32_to_cpu(entry->type) - type_in; - - if (!diff) - return entry; - if (diff < 0) - min_idx = i + 1; - else if (i) - max_idx = i - 1; - else - return NULL; - } - return NULL; -} - /* * ntfs_look_for_free_space - Look for a free space in bitmap. */ diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 2f6fb6ceaeca..e9f6898ec924 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -584,8 +584,6 @@ int ntfs_fix_post_read(struct NTFS_RECORD_HEADER *rhdr, size_t bytes, bool simple); int ntfs_extend_init(struct ntfs_sb_info *sbi); int ntfs_loadlog_and_replay(struct ntfs_inode *ni, struct ntfs_sb_info *sbi); -const struct ATTR_DEF_ENTRY *ntfs_query_def(struct ntfs_sb_info *sbi, - enum ATTR_TYPE Type); int ntfs_look_for_free_space(struct ntfs_sb_info *sbi, CLST lcn, CLST len, CLST *new_lcn, CLST *new_len, enum ALLOCATE_OPT opt); From patchwork Fri Oct 21 16:53:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 6874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp804085wrr; Fri, 21 Oct 2022 09:59:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7pr0dxKErbMXgQkQp7D6lzsXlVGDIRekrCqVFVMm7fgTQFZWS6zLskesitruzRwXIOwxgU X-Received: by 2002:a17:907:6d03:b0:782:abba:936c with SMTP id sa3-20020a1709076d0300b00782abba936cmr16387553ejc.758.1666371562844; Fri, 21 Oct 2022 09:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666371562; cv=none; d=google.com; s=arc-20160816; b=aXuhb9QXrINqAA1iyApMW/TP+WbXZYZd7YnHT62MR6XfRKAPqTgHwHVQuMh7y1feR0 3OoFhpQX5fuZ4oMs1l0zp2MGuxCvPd5Vhn/nRwdqBceCpClHfcN3tbNgWhQgfTR4q9GM K4FeiOpqU0rkT3YOlDl/K1eDh/3dO36PF1idHtLWdvxQYW2nLraAuz4iQXoW4xZZF6qB O6+z8aZr80v7aMbCcJS6D5E02BE60r4p5ftVJ9082MLTHF4kscA0NGXKRhxlhh7RLlJJ VR9bxbqc8/KZRnr0pvP3t/rxnGxDmPwXvjONk2pz2v+cldpdz+1OLxNMmBXWHHAVSwD9 R3LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=d0P/O+Kp+C+ez1qFGFR5y9BK+bKwVlzJw6ae9PLolSM=; b=LOI10trPbUhgxeudkzYz62D5avLEu4AfWhdgDpPxGmxF/cJyU411DNDy7CvJ76JOnb uR2zRR4Ami7z5A+kasMnFlfaTGvlCAISpE+PsaLRnI88c1AhMCIC6pPWNCmebmDtCI1o M8LeAoWJklwQtiX75tNuxQFXoPWrAE2WSo/VgAJLW9hsXJafzUxl32MEIILcLQwq+O9l duR0oKDJ90Wht9vb1g7Kiw6hc0yAzoSHmLtDWER4IRCe8IpUEHbo5e5i3hjTZPq7yu/m /AJaamt8XkMWXDjp4TqGjmxcGtRfdmXGhuNoAQ3kX/H3pW6o7LCBVx3P+4ze2fxTILDN 3M/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=AYfjMIA9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs41-20020a1709072d2900b0078de536a3cdsi21318333ejc.119.2022.10.21.09.58.56; Fri, 21 Oct 2022 09:59:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=AYfjMIA9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbiJUQxP (ORCPT + 99 others); Fri, 21 Oct 2022 12:53:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbiJUQxM (ORCPT ); Fri, 21 Oct 2022 12:53:12 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 430A228C31E; Fri, 21 Oct 2022 09:53:08 -0700 (PDT) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 734F32201; Fri, 21 Oct 2022 16:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1666371028; bh=d0P/O+Kp+C+ez1qFGFR5y9BK+bKwVlzJw6ae9PLolSM=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=AYfjMIA9L2KLwAun2Hkba60Oxx3kY9AoQZHIVEE56wUtfe7sM0KRRd6pr11wUCluk /+7UAeTeQQX0SJWuDlDvgTuHFhYAm26ykejFtbm5eu5X5VE6eqSOwGiBKSUZIxDVcZ 1NxDhZxhZ2AE+UcowsS6lWhn9rJxCOB5MdpByo4c= Received: from [172.30.8.65] (172.30.8.65) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Fri, 21 Oct 2022 19:53:01 +0300 Message-ID: <118f7c57-2b66-6ac6-f2e8-f1eccff97ea5@paragon-software.com> Date: Fri, 21 Oct 2022 19:53:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [PATCH 4/4] fs/ntfs3: Simplify ntfs_update_mftmirr function Content-Language: en-US From: Konstantin Komarov To: CC: , References: <9a7d08c2-e503-ac1d-1621-20369c073530@paragon-software.com> In-Reply-To: <9a7d08c2-e503-ac1d-1621-20369c073530@paragon-software.com> X-Originating-IP: [172.30.8.65] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747317227808750899?= X-GMAIL-MSGID: =?utf-8?q?1747317227808750899?= Make err assignment in one place. Signed-off-by: Konstantin Komarov --- fs/ntfs3/fsntfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 99dc2a287eab..3fe2de74eeaf 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -801,7 +801,6 @@ void ntfs_update_mftmirr(struct ntfs_sb_info *sbi, int wait) if (!(sbi->flags & NTFS_FLAGS_MFTMIRR)) return; - err = 0; bytes = sbi->mft.recs_mirr << sbi->record_bits; block1 = sbi->mft.lbo >> sb->s_blocksize_bits; block2 = sbi->mft.lbo2 >> sb->s_blocksize_bits; @@ -831,8 +830,7 @@ void ntfs_update_mftmirr(struct ntfs_sb_info *sbi, int wait) put_bh(bh1); bh1 = NULL; - if (wait) - err = sync_dirty_buffer(bh2); + err = wait ? sync_dirty_buffer(bh2) : 0; put_bh(bh2); if (err)