[PATCH 2/4] [PATCH] JFS: return correct error when i-node allocation failed
[email protected] (Dave Kleikamp) Wed, 20 Sep 2006 15:52:19 -0500 (CDT)
| Newsgroups | gmane.comp.file-systems.jfs.patches |
|---|---|
| Message-ID | <[email protected]> |
[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: Akinobu Mita <[email protected]> Signed-off-by: Dave Kleikamp <[email protected]> --- commit 2b46f77976f798f3fe800809a1d0ed38763c71c8 tree dc02e78cca68f6a7952f3ece9581914dfedcaab8 parent bdc3d9e5af7d9c105be734dd7b5c3f1d9425a15a author Akinobu Mita <[email protected]> Thu, 14 Sep 2006 09:22:38 -0500 committer Dave Kleikamp <[email protected]> Thu, 14 Sep 2006 09:22:38 -0500 fs/jfs/jfs_dtree.c | 4 ++-- fs/jfs/jfs_inode.c | 9 +++++---- fs/jfs/jfs_unicode.c | 2 +- fs/jfs/namei.c | 17 ++++++++--------- fs/jfs/super.c | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c index 6c3f083..a9f2604 100644 --- a/fs/jfs/jfs_dtree.c +++ b/fs/jfs/jfs_dtree.c @@ -3780,13 +3780,13 @@ static int ciGetLeafPrefixKey(dtpage_t * lkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), GFP_KERNEL); if (lkey.name == NULL) - return -ENOSPC; + return -ENOMEM; rkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), GFP_KERNEL); if (rkey.name == NULL) { kfree(lkey.name); - return -ENOSPC; + return -ENOMEM; } /* get left and right key */ diff --git a/fs/jfs/jfs_inode.c b/fs/jfs/jfs_inode.c index 495df40..09adecf 100644 --- a/fs/jfs/jfs_inode.c +++ b/fs/jfs/jfs_inode.c @@ -61,7 +61,7 @@ struct inode *ialloc(struct inode *paren inode = new_inode(sb); if (!inode) { jfs_warn("ialloc: new_inode returned NULL!"); - return inode; + return ERR_PTR(-ENOMEM); } jfs_inode = JFS_IP(inode); @@ -69,9 +69,10 @@ struct inode *ialloc(struct inode *paren rc = diAlloc(parent, S_ISDIR(mode), inode); if (rc) { jfs_warn("ialloc: diAlloc returned %d!", rc); - make_bad_inode(inode); + if (rc == -EIO) + make_bad_inode(inode); iput(inode); - return NULL; + return ERR_PTR(rc); } inode->i_uid = current->fsuid; @@ -97,7 +98,7 @@ struct inode *ialloc(struct inode *paren inode->i_flags |= S_NOQUOTA; inode->i_nlink = 0; iput(inode); - return NULL; + return ERR_PTR(-EDQUOT); } inode->i_mode = mode; diff --git a/fs/jfs/jfs_unicode.c b/fs/jfs/jfs_unicode.c index f327dec..0543f7f 100644 --- a/fs/jfs/jfs_unicode.c +++ b/fs/jfs/jfs_unicode.c @@ -124,7 +124,7 @@ int get_UCSname(struct component_name * kmalloc((length + 1) * sizeof(wchar_t), GFP_NOFS); if (uniName->name == NULL) - return -ENOSPC; + return -ENOMEM; uniName->namlen = jfs_strtoUCS(uniName->name, dentry->d_name.name, length, nls_tab); diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 295268a..f3009cc 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -97,8 +97,8 @@ static int jfs_create(struct inode *dip, * begin the transaction before we search the directory. */ ip = ialloc(dip, mode); - if (ip == NULL) { - rc = -ENOSPC; + if (IS_ERR(ip)) { + rc = PTR_ERR(ip); goto out2; } @@ -231,8 +231,8 @@ static int jfs_mkdir(struct inode *dip, * begin the transaction before we search the directory. */ ip = ialloc(dip, S_IFDIR | mode); - if (ip == NULL) { - rc = -ENOSPC; + if (IS_ERR(ip)) { + rc = PTR_ERR(ip); goto out2; } @@ -908,8 +908,8 @@ static int jfs_symlink(struct inode *dip * (iAlloc() returns new, locked inode) */ ip = ialloc(dip, S_IFLNK | 0777); - if (ip == NULL) { - rc = -ENOSPC; + if (IS_ERR(ip)) { + rc = PTR_ERR(ip); goto out2; } @@ -980,7 +980,6 @@ static int jfs_symlink(struct inode *dip xlen = xsize >> JFS_SBI(sb)->l2bsize; if ((rc = xtInsert(tid, ip, 0, 0, xlen, &xaddr, 0))) { txAbort(tid, 0); - rc = -ENOSPC; goto out3; } extent = xaddr; @@ -1352,8 +1351,8 @@ static int jfs_mknod(struct inode *dir, goto out; ip = ialloc(dir, mode); - if (ip == NULL) { - rc = -ENOSPC; + if (IS_ERR(ip)) { + rc = PTR_ERR(ip); goto out1; } jfs_ip = JFS_IP(ip); diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 143bcd1..fc69515 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -422,7 +422,7 @@ static int jfs_fill_super(struct super_b sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL); if (!sbi) - return -ENOSPC; + return -ENOMEM; sb->s_fs_info = sbi; sbi->sb = sb; sbi->uid = sbi->gid = sbi->umask = -1; ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV