* [PATCH 0/4] fs/ntfs3: Bugfix and refactoring
@ 2022-10-21 16:50 Konstantin Komarov
2022-10-21 16:51 ` [PATCH 1/4] fs/ntfs3: Add ntfs_bitmap_weight_le function " Konstantin Komarov
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Konstantin Komarov @ 2022-10-21 16:50 UTC (permalink / raw)
To: ntfs3; +Cc: linux-kernel, linux-fsdevel
[PATCH 0/4] fs/ntfs3: Bugfix and refactoring
First part of fixes and refactoring for ntfs3.
These patches must be applied after series
"fs/ntfs3: Fixes for big endian systems", that was missed by me.
Konstantin Komarov (4):
fs/ntfs3: Add ntfs_bitmap_weight_le function and refactoring
fs/ntfs3: Fix sparse problems
fs/ntfs3: Remove unused functions
fs/ntfs3: Simplify ntfs_update_mftmirr function
fs/ntfs3/attrib.c | 34 ++-------------
fs/ntfs3/bitfunc.c | 4 +-
fs/ntfs3/bitmap.c | 100 +++++++++++++++++++++++++--------------------
fs/ntfs3/dir.c | 4 +-
fs/ntfs3/frecord.c | 3 +-
fs/ntfs3/fsntfs.c | 33 +--------------
fs/ntfs3/namei.c | 13 +++---
fs/ntfs3/ntfs_fs.h | 13 +++---
8 files changed, 77 insertions(+), 127 deletions(-)
--
2.37.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] fs/ntfs3: Add ntfs_bitmap_weight_le function and refactoring
2022-10-21 16:50 [PATCH 0/4] fs/ntfs3: Bugfix and refactoring Konstantin Komarov
@ 2022-10-21 16:51 ` Konstantin Komarov
2022-10-21 16:52 ` [PATCH 2/4] fs/ntfs3: Fix sparse problems Konstantin Komarov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Konstantin Komarov @ 2022-10-21 16:51 UTC (permalink / raw)
To: ntfs3; +Cc: linux-kernel, linux-fsdevel
Added ntfs_bitmap_weight_le function.
Changed argument types of bits/bitmap functions.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
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,
--
2.37.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] fs/ntfs3: Fix sparse problems
2022-10-21 16:50 [PATCH 0/4] fs/ntfs3: Bugfix and refactoring Konstantin Komarov
2022-10-21 16:51 ` [PATCH 1/4] fs/ntfs3: Add ntfs_bitmap_weight_le function " Konstantin Komarov
@ 2022-10-21 16:52 ` Konstantin Komarov
2022-10-21 16:52 ` [PATCH 3/4] fs/ntfs3: Remove unused functions Konstantin Komarov
2022-10-21 16:53 ` [PATCH 4/4] fs/ntfs3: Simplify ntfs_update_mftmirr function Konstantin Komarov
3 siblings, 0 replies; 5+ messages in thread
From: Konstantin Komarov @ 2022-10-21 16:52 UTC (permalink / raw)
To: ntfs3; +Cc: linux-kernel, linux-fsdevel
Fixing various problems, detected by sparse.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
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);
--
2.37.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] fs/ntfs3: Remove unused functions
2022-10-21 16:50 [PATCH 0/4] fs/ntfs3: Bugfix and refactoring Konstantin Komarov
2022-10-21 16:51 ` [PATCH 1/4] fs/ntfs3: Add ntfs_bitmap_weight_le function " Konstantin Komarov
2022-10-21 16:52 ` [PATCH 2/4] fs/ntfs3: Fix sparse problems Konstantin Komarov
@ 2022-10-21 16:52 ` Konstantin Komarov
2022-10-21 16:53 ` [PATCH 4/4] fs/ntfs3: Simplify ntfs_update_mftmirr function Konstantin Komarov
3 siblings, 0 replies; 5+ messages in thread
From: Konstantin Komarov @ 2022-10-21 16:52 UTC (permalink / raw)
To: ntfs3; +Cc: linux-kernel, linux-fsdevel
Removed attr_must_be_resident and ntfs_query_def.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
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);
--
2.37.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] fs/ntfs3: Simplify ntfs_update_mftmirr function
2022-10-21 16:50 [PATCH 0/4] fs/ntfs3: Bugfix and refactoring Konstantin Komarov
` (2 preceding siblings ...)
2022-10-21 16:52 ` [PATCH 3/4] fs/ntfs3: Remove unused functions Konstantin Komarov
@ 2022-10-21 16:53 ` Konstantin Komarov
3 siblings, 0 replies; 5+ messages in thread
From: Konstantin Komarov @ 2022-10-21 16:53 UTC (permalink / raw)
To: ntfs3; +Cc: linux-kernel, linux-fsdevel
Make err assignment in one place.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
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)
--
2.37.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-21 16:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-21 16:50 [PATCH 0/4] fs/ntfs3: Bugfix and refactoring Konstantin Komarov
2022-10-21 16:51 ` [PATCH 1/4] fs/ntfs3: Add ntfs_bitmap_weight_le function " Konstantin Komarov
2022-10-21 16:52 ` [PATCH 2/4] fs/ntfs3: Fix sparse problems Konstantin Komarov
2022-10-21 16:52 ` [PATCH 3/4] fs/ntfs3: Remove unused functions Konstantin Komarov
2022-10-21 16:53 ` [PATCH 4/4] fs/ntfs3: Simplify ntfs_update_mftmirr function Konstantin Komarov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).