fs/ntfs3: New function ntfs_bad_inode
There are repetitive steps in case of bad inode This commit wraps them in function Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
parent
8335ebe195
commit
c12df45ee6
|
@ -1912,7 +1912,7 @@ int attr_collapse_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
|
|||
out:
|
||||
up_write(&ni->file.run_lock);
|
||||
if (err)
|
||||
make_bad_inode(&ni->vfs_inode);
|
||||
_ntfs_bad_inode(&ni->vfs_inode);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -2092,10 +2092,8 @@ int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size)
|
|||
|
||||
out:
|
||||
up_write(&ni->file.run_lock);
|
||||
if (err) {
|
||||
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
|
||||
make_bad_inode(&ni->vfs_inode);
|
||||
}
|
||||
if (err)
|
||||
_ntfs_bad_inode(&ni->vfs_inode);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -2282,7 +2280,7 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
|
|||
|
||||
up_write(&ni->file.run_lock);
|
||||
if (err)
|
||||
make_bad_inode(&ni->vfs_inode);
|
||||
_ntfs_bad_inode(&ni->vfs_inode);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -2328,10 +2328,8 @@ int ni_decompress_file(struct ntfs_inode *ni)
|
|||
|
||||
out:
|
||||
kfree(pages);
|
||||
if (err) {
|
||||
make_bad_inode(inode);
|
||||
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
|
||||
}
|
||||
if (err)
|
||||
_ntfs_bad_inode(inode);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -877,6 +877,20 @@ void ntfs_update_mftmirr(struct ntfs_sb_info *sbi, int wait)
|
|||
sbi->flags &= ~NTFS_FLAGS_MFTMIRR;
|
||||
}
|
||||
|
||||
/*
|
||||
* ntfs_bad_inode
|
||||
*
|
||||
* Marks inode as bad and marks fs as 'dirty'
|
||||
*/
|
||||
void ntfs_bad_inode(struct inode *inode, const char *hint)
|
||||
{
|
||||
struct ntfs_sb_info *sbi = inode->i_sb->s_fs_info;
|
||||
|
||||
ntfs_inode_err(inode, "%s", hint);
|
||||
make_bad_inode(inode);
|
||||
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* ntfs_set_state
|
||||
*
|
||||
|
|
|
@ -501,7 +501,7 @@ struct inode *ntfs_iget5(struct super_block *sb, const struct MFT_REF *ref,
|
|||
inode = ntfs_read_mft(inode, name, ref);
|
||||
else if (ref->seq != ntfs_i(inode)->mi.mrec->seq) {
|
||||
/* Inode overlaps? */
|
||||
make_bad_inode(inode);
|
||||
_ntfs_bad_inode(inode);
|
||||
}
|
||||
|
||||
return inode;
|
||||
|
@ -1725,9 +1725,7 @@ int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry)
|
|||
if (inode->i_nlink)
|
||||
mark_inode_dirty(inode);
|
||||
} else if (!ni_remove_name_undo(dir_ni, ni, de, de2, undo_remove)) {
|
||||
make_bad_inode(inode);
|
||||
ntfs_inode_err(inode, "failed to undo unlink");
|
||||
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
|
||||
_ntfs_bad_inode(inode);
|
||||
} else {
|
||||
if (ni_is_dirty(dir))
|
||||
mark_inode_dirty(dir);
|
||||
|
|
|
@ -308,9 +308,7 @@ static int ntfs_rename(struct user_namespace *mnt_userns, struct inode *dir,
|
|||
err = ni_rename(dir_ni, new_dir_ni, ni, de, new_de, &is_bad);
|
||||
if (is_bad) {
|
||||
/* Restore after failed rename failed too. */
|
||||
make_bad_inode(inode);
|
||||
ntfs_inode_err(inode, "failed to undo rename");
|
||||
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
|
||||
_ntfs_bad_inode(inode);
|
||||
} else if (!err) {
|
||||
inode->i_ctime = dir->i_ctime = dir->i_mtime =
|
||||
current_time(dir);
|
||||
|
|
|
@ -593,6 +593,8 @@ void ntfs_mark_rec_free(struct ntfs_sb_info *sbi, CLST rno, bool is_mft);
|
|||
int ntfs_clear_mft_tail(struct ntfs_sb_info *sbi, size_t from, size_t to);
|
||||
int ntfs_refresh_zone(struct ntfs_sb_info *sbi);
|
||||
void ntfs_update_mftmirr(struct ntfs_sb_info *sbi, int wait);
|
||||
void ntfs_bad_inode(struct inode *inode, const char *hint);
|
||||
#define _ntfs_bad_inode(i) ntfs_bad_inode(i, __func__)
|
||||
enum NTFS_DIRTY_FLAGS {
|
||||
NTFS_DIRTY_CLEAR = 0,
|
||||
NTFS_DIRTY_DIRTY = 1,
|
||||
|
|
Loading…
Reference in New Issue