提交 55cad3d5 编写于 作者: J Jan Kara 提交者: Cheng Jian

ext4: move functions in super.c

mainline inclusion
from mainline-v5.11-rc1
commit 40676623
category: bugfix
bugzilla: 46758
CVE: NA

-----------------------------------------------

Just move error info related functions in super.c close to
ext4_handle_error(). We'll want to combine save_error_info() with
ext4_handle_error() and this makes change more obvious and saves a
forward declaration as well. No functional change.
Signed-off-by: NJan Kara <jack@suse.cz>
Reviewed-by: NAndreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/20201127113405.26867-6-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>

conflicts:
fs/ext4/super.c
Signed-off-by: NYe Bin <yebin10@huawei.com>
Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 eca58bf9
...@@ -363,6 +363,92 @@ static time64_t __ext4_get_tstamp(__le32 *lo, __u8 *hi) ...@@ -363,6 +363,92 @@ static time64_t __ext4_get_tstamp(__le32 *lo, __u8 *hi)
#define ext4_get_tstamp(es, tstamp) \ #define ext4_get_tstamp(es, tstamp) \
__ext4_get_tstamp(&(es)->tstamp, &(es)->tstamp ## _hi) __ext4_get_tstamp(&(es)->tstamp, &(es)->tstamp ## _hi)
/*
* The del_gendisk() function uninitializes the disk-specific data
* structures, including the bdi structure, without telling anyone
* else. Once this happens, any attempt to call mark_buffer_dirty()
* (for example, by ext4_commit_super), will cause a kernel OOPS.
* This is a kludge to prevent these oops until we can put in a proper
* hook in del_gendisk() to inform the VFS and file system layers.
*/
static int block_device_ejected(struct super_block *sb)
{
struct inode *bd_inode = sb->s_bdev->bd_inode;
struct backing_dev_info *bdi = inode_to_bdi(bd_inode);
return bdi->dev == NULL;
}
static void ext4_journal_commit_callback(journal_t *journal, transaction_t *txn)
{
struct super_block *sb = journal->j_private;
struct ext4_sb_info *sbi = EXT4_SB(sb);
int error = is_journal_aborted(journal);
struct ext4_journal_cb_entry *jce;
BUG_ON(txn->t_state == T_FINISHED);
ext4_process_freed_data(sb, txn->t_tid);
spin_lock(&sbi->s_md_lock);
while (!list_empty(&txn->t_private_list)) {
jce = list_entry(txn->t_private_list.next,
struct ext4_journal_cb_entry, jce_list);
list_del_init(&jce->jce_list);
spin_unlock(&sbi->s_md_lock);
jce->jce_func(sb, jce, error);
spin_lock(&sbi->s_md_lock);
}
spin_unlock(&sbi->s_md_lock);
}
static bool system_going_down(void)
{
return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF
|| system_state == SYSTEM_RESTART;
}
static void ext4_netlink_send_info(struct super_block *sb, int ext4_errno)
{
int size;
sk_buff_data_t old_tail;
struct sk_buff *skb;
struct nlmsghdr *nlh;
struct ext4_err_msg *msg;
if (ext4nl) {
if (IS_EXT2_SB(sb))
return;
size = NLMSG_SPACE(sizeof(struct ext4_err_msg));
skb = alloc_skb(size, GFP_ATOMIC);
if (!skb) {
printk(KERN_ERR "Cannot alloc skb!");
return;
}
old_tail = skb->tail;
nlh = nlmsg_put(skb, 0, 0, NLMSG_ERROR, size - sizeof(*nlh), 0);
if (!nlh)
goto nlmsg_failure;
msg = (struct ext4_err_msg *)NLMSG_DATA(nlh);
if (IS_EXT3_SB(sb))
msg->magic = EXT3_ERROR_MAGIC;
else
msg->magic = EXT4_ERROR_MAGIC;
memcpy(msg->s_id, sb->s_id, sizeof(sb->s_id));
msg->s_flags = sb->s_flags;
msg->ext4_errno = ext4_errno;
nlh->nlmsg_len = skb->tail - old_tail;
NETLINK_CB(skb).portid = 0;
NETLINK_CB(skb).dst_group = NL_EXT4_ERROR_GROUP;
netlink_broadcast(ext4nl, skb, 0, NL_EXT4_ERROR_GROUP,
GFP_ATOMIC);
return;
nlmsg_failure:
if (skb)
kfree_skb(skb);
}
}
static void __save_error_info(struct super_block *sb, int error, static void __save_error_info(struct super_block *sb, int error,
__u32 ino, __u64 block, __u32 ino, __u64 block,
const char *func, unsigned int line) const char *func, unsigned int line)
...@@ -461,92 +547,6 @@ static void save_error_info(struct super_block *sb, int error, ...@@ -461,92 +547,6 @@ static void save_error_info(struct super_block *sb, int error,
ext4_commit_super(sb, 1); ext4_commit_super(sb, 1);
} }
/*
* The del_gendisk() function uninitializes the disk-specific data
* structures, including the bdi structure, without telling anyone
* else. Once this happens, any attempt to call mark_buffer_dirty()
* (for example, by ext4_commit_super), will cause a kernel OOPS.
* This is a kludge to prevent these oops until we can put in a proper
* hook in del_gendisk() to inform the VFS and file system layers.
*/
static int block_device_ejected(struct super_block *sb)
{
struct inode *bd_inode = sb->s_bdev->bd_inode;
struct backing_dev_info *bdi = inode_to_bdi(bd_inode);
return bdi->dev == NULL;
}
static void ext4_journal_commit_callback(journal_t *journal, transaction_t *txn)
{
struct super_block *sb = journal->j_private;
struct ext4_sb_info *sbi = EXT4_SB(sb);
int error = is_journal_aborted(journal);
struct ext4_journal_cb_entry *jce;
BUG_ON(txn->t_state == T_FINISHED);
ext4_process_freed_data(sb, txn->t_tid);
spin_lock(&sbi->s_md_lock);
while (!list_empty(&txn->t_private_list)) {
jce = list_entry(txn->t_private_list.next,
struct ext4_journal_cb_entry, jce_list);
list_del_init(&jce->jce_list);
spin_unlock(&sbi->s_md_lock);
jce->jce_func(sb, jce, error);
spin_lock(&sbi->s_md_lock);
}
spin_unlock(&sbi->s_md_lock);
}
static bool system_going_down(void)
{
return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF
|| system_state == SYSTEM_RESTART;
}
static void ext4_netlink_send_info(struct super_block *sb, int ext4_errno)
{
int size;
sk_buff_data_t old_tail;
struct sk_buff *skb;
struct nlmsghdr *nlh;
struct ext4_err_msg *msg;
if (ext4nl) {
if (IS_EXT2_SB(sb))
return;
size = NLMSG_SPACE(sizeof(struct ext4_err_msg));
skb = alloc_skb(size, GFP_ATOMIC);
if (!skb) {
printk(KERN_ERR "Cannot alloc skb!");
return;
}
old_tail = skb->tail;
nlh = nlmsg_put(skb, 0, 0, NLMSG_ERROR, size - sizeof(*nlh), 0);
if (!nlh)
goto nlmsg_failure;
msg = (struct ext4_err_msg *)NLMSG_DATA(nlh);
if (IS_EXT3_SB(sb))
msg->magic = EXT3_ERROR_MAGIC;
else
msg->magic = EXT4_ERROR_MAGIC;
memcpy(msg->s_id, sb->s_id, sizeof(sb->s_id));
msg->s_flags = sb->s_flags;
msg->ext4_errno = ext4_errno;
nlh->nlmsg_len = skb->tail - old_tail;
NETLINK_CB(skb).portid = 0;
NETLINK_CB(skb).dst_group = NL_EXT4_ERROR_GROUP;
netlink_broadcast(ext4nl, skb, 0, NL_EXT4_ERROR_GROUP,
GFP_ATOMIC);
return;
nlmsg_failure:
if (skb)
kfree_skb(skb);
}
}
/* Deal with the reporting of failure conditions on a filesystem such as /* Deal with the reporting of failure conditions on a filesystem such as
* inconsistencies detected or read IO failures. * inconsistencies detected or read IO failures.
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册