提交 087387f9 编写于 作者: A Akinobu Mita 提交者: Dave Kleikamp

[PATCH] JFS: return correct error when i-node allocation failed

I have seen confusing behavior on JFS when I injected many intentional
slab allocation errors. The cp command failed with no disk space error
with enough disk space.

This patch makes:

- change the return value in case slab allocation failures happen
  from -ENOSPC to -ENOMEM

- ialloc() return error code so that the caller can know the reason
  of failures
Signed-off-by: NAkinobu Mita <mita@miraclelinux.com>
Signed-off-by: NDave Kleikamp <shaggy@austin.ibm.com>
(cherry picked from 2b46f77976f798f3fe800809a1d0ed38763c71c8 commit)
上级 2a6968a9
...@@ -3780,13 +3780,13 @@ static int ciGetLeafPrefixKey(dtpage_t * lp, int li, dtpage_t * rp, ...@@ -3780,13 +3780,13 @@ static int ciGetLeafPrefixKey(dtpage_t * lp, int li, dtpage_t * rp,
lkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), lkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
GFP_KERNEL); GFP_KERNEL);
if (lkey.name == NULL) if (lkey.name == NULL)
return -ENOSPC; return -ENOMEM;
rkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), rkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
GFP_KERNEL); GFP_KERNEL);
if (rkey.name == NULL) { if (rkey.name == NULL) {
kfree(lkey.name); kfree(lkey.name);
return -ENOSPC; return -ENOMEM;
} }
/* get left and right key */ /* get left and right key */
......
...@@ -61,7 +61,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode) ...@@ -61,7 +61,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
inode = new_inode(sb); inode = new_inode(sb);
if (!inode) { if (!inode) {
jfs_warn("ialloc: new_inode returned NULL!"); jfs_warn("ialloc: new_inode returned NULL!");
return inode; return ERR_PTR(-ENOMEM);
} }
jfs_inode = JFS_IP(inode); jfs_inode = JFS_IP(inode);
...@@ -69,9 +69,10 @@ struct inode *ialloc(struct inode *parent, umode_t mode) ...@@ -69,9 +69,10 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
rc = diAlloc(parent, S_ISDIR(mode), inode); rc = diAlloc(parent, S_ISDIR(mode), inode);
if (rc) { if (rc) {
jfs_warn("ialloc: diAlloc returned %d!", rc); jfs_warn("ialloc: diAlloc returned %d!", rc);
if (rc == -EIO)
make_bad_inode(inode); make_bad_inode(inode);
iput(inode); iput(inode);
return NULL; return ERR_PTR(rc);
} }
inode->i_uid = current->fsuid; inode->i_uid = current->fsuid;
...@@ -97,7 +98,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode) ...@@ -97,7 +98,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
inode->i_flags |= S_NOQUOTA; inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0; inode->i_nlink = 0;
iput(inode); iput(inode);
return NULL; return ERR_PTR(-EDQUOT);
} }
inode->i_mode = mode; inode->i_mode = mode;
......
...@@ -124,7 +124,7 @@ int get_UCSname(struct component_name * uniName, struct dentry *dentry) ...@@ -124,7 +124,7 @@ int get_UCSname(struct component_name * uniName, struct dentry *dentry)
kmalloc((length + 1) * sizeof(wchar_t), GFP_NOFS); kmalloc((length + 1) * sizeof(wchar_t), GFP_NOFS);
if (uniName->name == NULL) if (uniName->name == NULL)
return -ENOSPC; return -ENOMEM;
uniName->namlen = jfs_strtoUCS(uniName->name, dentry->d_name.name, uniName->namlen = jfs_strtoUCS(uniName->name, dentry->d_name.name,
length, nls_tab); length, nls_tab);
......
...@@ -97,8 +97,8 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, ...@@ -97,8 +97,8 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
* begin the transaction before we search the directory. * begin the transaction before we search the directory.
*/ */
ip = ialloc(dip, mode); ip = ialloc(dip, mode);
if (ip == NULL) { if (IS_ERR(ip)) {
rc = -ENOSPC; rc = PTR_ERR(ip);
goto out2; goto out2;
} }
...@@ -231,8 +231,8 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) ...@@ -231,8 +231,8 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
* begin the transaction before we search the directory. * begin the transaction before we search the directory.
*/ */
ip = ialloc(dip, S_IFDIR | mode); ip = ialloc(dip, S_IFDIR | mode);
if (ip == NULL) { if (IS_ERR(ip)) {
rc = -ENOSPC; rc = PTR_ERR(ip);
goto out2; goto out2;
} }
...@@ -906,8 +906,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, ...@@ -906,8 +906,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
* (iAlloc() returns new, locked inode) * (iAlloc() returns new, locked inode)
*/ */
ip = ialloc(dip, S_IFLNK | 0777); ip = ialloc(dip, S_IFLNK | 0777);
if (ip == NULL) { if (IS_ERR(ip)) {
rc = -ENOSPC; rc = PTR_ERR(ip);
goto out2; goto out2;
} }
...@@ -978,7 +978,6 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, ...@@ -978,7 +978,6 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
xlen = xsize >> JFS_SBI(sb)->l2bsize; xlen = xsize >> JFS_SBI(sb)->l2bsize;
if ((rc = xtInsert(tid, ip, 0, 0, xlen, &xaddr, 0))) { if ((rc = xtInsert(tid, ip, 0, 0, xlen, &xaddr, 0))) {
txAbort(tid, 0); txAbort(tid, 0);
rc = -ENOSPC;
goto out3; goto out3;
} }
extent = xaddr; extent = xaddr;
...@@ -1350,8 +1349,8 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -1350,8 +1349,8 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry,
goto out; goto out;
ip = ialloc(dir, mode); ip = ialloc(dir, mode);
if (ip == NULL) { if (IS_ERR(ip)) {
rc = -ENOSPC; rc = PTR_ERR(ip);
goto out1; goto out1;
} }
jfs_ip = JFS_IP(ip); jfs_ip = JFS_IP(ip);
......
...@@ -422,7 +422,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -422,7 +422,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL); sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL);
if (!sbi) if (!sbi)
return -ENOSPC; return -ENOMEM;
sb->s_fs_info = sbi; sb->s_fs_info = sbi;
sbi->sb = sb; sbi->sb = sb;
sbi->uid = sbi->gid = sbi->umask = -1; sbi->uid = sbi->gid = sbi->umask = -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册