ext4: Properly count journal credits for long symlinks
[deliverable/linux.git] / fs / ext4 / namei.c
index 8c9babac43dc941fa62ece2773f234044b8a5b7b..f8068c7bae9fd05c7d94880dd909c1f17df7dad5 100644 (file)
@@ -289,7 +289,7 @@ static struct stats dx_show_leaf(struct dx_hash_info *hinfo, struct ext4_dir_ent
                                while (len--) printk("%c", *name++);
                                ext4fs_dirhash(de->name, de->name_len, &h);
                                printk(":%x.%u ", h.hash,
-                                      ((char *) de - base));
+                                      (unsigned) ((char *) de - base));
                        }
                        space += EXT4_DIR_REC_LEN(de->name_len);
                        names++;
@@ -1013,7 +1013,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct q
 
        *err = -ENOENT;
 errout:
-       dxtrace(printk(KERN_DEBUG "%s not found\n", name));
+       dxtrace(printk(KERN_DEBUG "%s not found\n", d_name->name));
        dx_release (frames);
        return NULL;
 }
@@ -1985,18 +1985,11 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
        if (!list_empty(&EXT4_I(inode)->i_orphan))
                goto out_unlock;
 
-       /* Orphan handling is only valid for files with data blocks
-        * being truncated, or files being unlinked. */
-
-       /* @@@ FIXME: Observation from aviro:
-        * I think I can trigger J_ASSERT in ext4_orphan_add().  We block
-        * here (on s_orphan_lock), so race with ext4_link() which might bump
-        * ->i_nlink. For, say it, character device. Not a regular file,
-        * not a directory, not a symlink and ->i_nlink > 0.
-        *
-        * tytso, 4/25/2009: I'm not sure how that could happen;
-        * shouldn't the fs core protect us from these sort of
-        * unlink()/link() races?
+       /*
+        * Orphan handling is only valid for files with data blocks
+        * being truncated, or files being unlinked. Note that we either
+        * hold i_mutex, or the inode can not be referenced from outside,
+        * so i_nlink should not be bumped due to race
         */
        J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
                  S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
@@ -2260,9 +2253,11 @@ static int ext4_symlink(struct inode *dir,
                /*
                 * For non-fast symlinks, we just allocate inode and put it on
                 * orphan list in the first transaction => we need bitmap,
-                * group descriptor, sb, inode block, quota blocks.
+                * group descriptor, sb, inode block, quota blocks, and
+                * possibly selinux xattr blocks.
                 */
-               credits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb);
+               credits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
+                         EXT4_XATTR_TRANS_BLOCKS;
        } else {
                /*
                 * Fast symlink. We have to add entry to directory
This page took 0.029258 seconds and 5 git commands to generate.