mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-28 16:56:26 +00:00
fs/ntfs3: Accumulated refactoring changes
Changes made to improve readability and debuggability. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
parent
678c1901af
commit
bac89bb33d
@ -710,20 +710,17 @@ int wnd_set_free(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
struct super_block *sb = wnd->sb;
|
struct super_block *sb = wnd->sb;
|
||||||
size_t bits0 = bits;
|
|
||||||
u32 wbits = 8 * sb->s_blocksize;
|
u32 wbits = 8 * sb->s_blocksize;
|
||||||
size_t iw = bit >> (sb->s_blocksize_bits + 3);
|
size_t iw = bit >> (sb->s_blocksize_bits + 3);
|
||||||
u32 wbit = bit & (wbits - 1);
|
u32 wbit = bit & (wbits - 1);
|
||||||
struct buffer_head *bh;
|
struct buffer_head *bh;
|
||||||
|
u32 op;
|
||||||
|
|
||||||
while (iw < wnd->nwnd && bits) {
|
for (; iw < wnd->nwnd && bits; iw++, bit += op, bits -= op, wbit = 0) {
|
||||||
u32 tail, op;
|
|
||||||
|
|
||||||
if (iw + 1 == wnd->nwnd)
|
if (iw + 1 == wnd->nwnd)
|
||||||
wbits = wnd->bits_last;
|
wbits = wnd->bits_last;
|
||||||
|
|
||||||
tail = wbits - wbit;
|
op = min_t(u32, wbits - wbit, bits);
|
||||||
op = min_t(u32, tail, bits);
|
|
||||||
|
|
||||||
bh = wnd_map(wnd, iw);
|
bh = wnd_map(wnd, iw);
|
||||||
if (IS_ERR(bh)) {
|
if (IS_ERR(bh)) {
|
||||||
@ -736,20 +733,15 @@ int wnd_set_free(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|||||||
ntfs_bitmap_clear_le(bh->b_data, wbit, op);
|
ntfs_bitmap_clear_le(bh->b_data, wbit, op);
|
||||||
|
|
||||||
wnd->free_bits[iw] += op;
|
wnd->free_bits[iw] += op;
|
||||||
|
wnd->total_zeroes += op;
|
||||||
|
|
||||||
set_buffer_uptodate(bh);
|
set_buffer_uptodate(bh);
|
||||||
mark_buffer_dirty(bh);
|
mark_buffer_dirty(bh);
|
||||||
unlock_buffer(bh);
|
unlock_buffer(bh);
|
||||||
put_bh(bh);
|
put_bh(bh);
|
||||||
|
|
||||||
wnd->total_zeroes += op;
|
wnd_add_free_ext(wnd, bit, op, false);
|
||||||
bits -= op;
|
|
||||||
wbit = 0;
|
|
||||||
iw += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wnd_add_free_ext(wnd, bit, bits0, false);
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,20 +752,17 @@ int wnd_set_used(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
struct super_block *sb = wnd->sb;
|
struct super_block *sb = wnd->sb;
|
||||||
size_t bits0 = bits;
|
|
||||||
size_t iw = bit >> (sb->s_blocksize_bits + 3);
|
size_t iw = bit >> (sb->s_blocksize_bits + 3);
|
||||||
u32 wbits = 8 * sb->s_blocksize;
|
u32 wbits = 8 * sb->s_blocksize;
|
||||||
u32 wbit = bit & (wbits - 1);
|
u32 wbit = bit & (wbits - 1);
|
||||||
struct buffer_head *bh;
|
struct buffer_head *bh;
|
||||||
|
u32 op;
|
||||||
|
|
||||||
while (iw < wnd->nwnd && bits) {
|
for (; iw < wnd->nwnd && bits; iw++, bit += op, bits -= op, wbit = 0) {
|
||||||
u32 tail, op;
|
|
||||||
|
|
||||||
if (unlikely(iw + 1 == wnd->nwnd))
|
if (unlikely(iw + 1 == wnd->nwnd))
|
||||||
wbits = wnd->bits_last;
|
wbits = wnd->bits_last;
|
||||||
|
|
||||||
tail = wbits - wbit;
|
op = min_t(u32, wbits - wbit, bits);
|
||||||
op = min_t(u32, tail, bits);
|
|
||||||
|
|
||||||
bh = wnd_map(wnd, iw);
|
bh = wnd_map(wnd, iw);
|
||||||
if (IS_ERR(bh)) {
|
if (IS_ERR(bh)) {
|
||||||
@ -785,21 +774,16 @@ int wnd_set_used(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|||||||
|
|
||||||
ntfs_bitmap_set_le(bh->b_data, wbit, op);
|
ntfs_bitmap_set_le(bh->b_data, wbit, op);
|
||||||
wnd->free_bits[iw] -= op;
|
wnd->free_bits[iw] -= op;
|
||||||
|
wnd->total_zeroes -= op;
|
||||||
|
|
||||||
set_buffer_uptodate(bh);
|
set_buffer_uptodate(bh);
|
||||||
mark_buffer_dirty(bh);
|
mark_buffer_dirty(bh);
|
||||||
unlock_buffer(bh);
|
unlock_buffer(bh);
|
||||||
put_bh(bh);
|
put_bh(bh);
|
||||||
|
|
||||||
wnd->total_zeroes -= op;
|
if (!RB_EMPTY_ROOT(&wnd->start_tree))
|
||||||
bits -= op;
|
wnd_remove_free_ext(wnd, bit, op);
|
||||||
wbit = 0;
|
|
||||||
iw += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RB_EMPTY_ROOT(&wnd->start_tree))
|
|
||||||
wnd_remove_free_ext(wnd, bit, bits0);
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -852,15 +836,13 @@ static bool wnd_is_free_hlp(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|||||||
size_t iw = bit >> (sb->s_blocksize_bits + 3);
|
size_t iw = bit >> (sb->s_blocksize_bits + 3);
|
||||||
u32 wbits = 8 * sb->s_blocksize;
|
u32 wbits = 8 * sb->s_blocksize;
|
||||||
u32 wbit = bit & (wbits - 1);
|
u32 wbit = bit & (wbits - 1);
|
||||||
|
u32 op;
|
||||||
|
|
||||||
while (iw < wnd->nwnd && bits) {
|
for (; iw < wnd->nwnd && bits; iw++, bits -= op, wbit = 0) {
|
||||||
u32 tail, op;
|
|
||||||
|
|
||||||
if (unlikely(iw + 1 == wnd->nwnd))
|
if (unlikely(iw + 1 == wnd->nwnd))
|
||||||
wbits = wnd->bits_last;
|
wbits = wnd->bits_last;
|
||||||
|
|
||||||
tail = wbits - wbit;
|
op = min_t(u32, wbits - wbit, bits);
|
||||||
op = min_t(u32, tail, bits);
|
|
||||||
|
|
||||||
if (wbits != wnd->free_bits[iw]) {
|
if (wbits != wnd->free_bits[iw]) {
|
||||||
bool ret;
|
bool ret;
|
||||||
@ -875,10 +857,6 @@ static bool wnd_is_free_hlp(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bits -= op;
|
|
||||||
wbit = 0;
|
|
||||||
iw += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -928,6 +906,7 @@ bool wnd_is_used(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|||||||
size_t iw = bit >> (sb->s_blocksize_bits + 3);
|
size_t iw = bit >> (sb->s_blocksize_bits + 3);
|
||||||
u32 wbits = 8 * sb->s_blocksize;
|
u32 wbits = 8 * sb->s_blocksize;
|
||||||
u32 wbit = bit & (wbits - 1);
|
u32 wbit = bit & (wbits - 1);
|
||||||
|
u32 op;
|
||||||
size_t end;
|
size_t end;
|
||||||
struct rb_node *n;
|
struct rb_node *n;
|
||||||
struct e_node *e;
|
struct e_node *e;
|
||||||
@ -945,14 +924,11 @@ bool wnd_is_used(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
use_wnd:
|
use_wnd:
|
||||||
while (iw < wnd->nwnd && bits) {
|
for (; iw < wnd->nwnd && bits; iw++, bits -= op, wbit = 0) {
|
||||||
u32 tail, op;
|
|
||||||
|
|
||||||
if (unlikely(iw + 1 == wnd->nwnd))
|
if (unlikely(iw + 1 == wnd->nwnd))
|
||||||
wbits = wnd->bits_last;
|
wbits = wnd->bits_last;
|
||||||
|
|
||||||
tail = wbits - wbit;
|
op = min_t(u32, wbits - wbit, bits);
|
||||||
op = min_t(u32, tail, bits);
|
|
||||||
|
|
||||||
if (wnd->free_bits[iw]) {
|
if (wnd->free_bits[iw]) {
|
||||||
bool ret;
|
bool ret;
|
||||||
@ -966,10 +942,6 @@ bool wnd_is_used(struct wnd_bitmap *wnd, size_t bit, size_t bits)
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bits -= op;
|
|
||||||
wbit = 0;
|
|
||||||
iw += 1;
|
|
||||||
}
|
}
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
|
@ -1958,7 +1958,6 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
|
|||||||
if (end > alloc_size)
|
if (end > alloc_size)
|
||||||
end = alloc_size;
|
end = alloc_size;
|
||||||
|
|
||||||
|
|
||||||
while (vbo < end) {
|
while (vbo < end) {
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
ok = run_lookup_entry(&run, vcn, &lcn, &clen, &idx);
|
ok = run_lookup_entry(&run, vcn, &lcn, &clen, &idx);
|
||||||
|
@ -2699,4 +2699,4 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len)
|
|||||||
out:
|
out:
|
||||||
__putname(uni);
|
__putname(uni);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1112,9 +1112,9 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
|
|||||||
err = wnd_set_used_safe(wnd, lcn, len, &done);
|
err = wnd_set_used_safe(wnd, lcn, len, &done);
|
||||||
if (zone) {
|
if (zone) {
|
||||||
/* Restore zone. Lock mft run. */
|
/* Restore zone. Lock mft run. */
|
||||||
struct rw_semaphore *lock;
|
struct rw_semaphore *lock =
|
||||||
lock = is_mounted(sbi) ? &sbi->mft.ni->file.run_lock :
|
is_mounted(sbi) ? &sbi->mft.ni->file.run_lock :
|
||||||
NULL;
|
NULL;
|
||||||
if (lock)
|
if (lock)
|
||||||
down_read(lock);
|
down_read(lock);
|
||||||
ntfs_refresh_zone(sbi);
|
ntfs_refresh_zone(sbi);
|
||||||
|
Loading…
Reference in New Issue
Block a user