|
@@ -151,26 +151,26 @@ struct dx_map_entry
|
|
|
|
|
|
static inline ext4_lblk_t dx_get_block(struct dx_entry *entry);
|
|
|
static void dx_set_block(struct dx_entry *entry, ext4_lblk_t value);
|
|
|
-static inline unsigned dx_get_hash (struct dx_entry *entry);
|
|
|
-static void dx_set_hash (struct dx_entry *entry, unsigned value);
|
|
|
-static unsigned dx_get_count (struct dx_entry *entries);
|
|
|
-static unsigned dx_get_limit (struct dx_entry *entries);
|
|
|
-static void dx_set_count (struct dx_entry *entries, unsigned value);
|
|
|
-static void dx_set_limit (struct dx_entry *entries, unsigned value);
|
|
|
-static unsigned dx_root_limit (struct inode *dir, unsigned infosize);
|
|
|
-static unsigned dx_node_limit (struct inode *dir);
|
|
|
+static inline unsigned dx_get_hash(struct dx_entry *entry);
|
|
|
+static void dx_set_hash(struct dx_entry *entry, unsigned value);
|
|
|
+static unsigned dx_get_count(struct dx_entry *entries);
|
|
|
+static unsigned dx_get_limit(struct dx_entry *entries);
|
|
|
+static void dx_set_count(struct dx_entry *entries, unsigned value);
|
|
|
+static void dx_set_limit(struct dx_entry *entries, unsigned value);
|
|
|
+static unsigned dx_root_limit(struct inode *dir, unsigned infosize);
|
|
|
+static unsigned dx_node_limit(struct inode *dir);
|
|
|
static struct dx_frame *dx_probe(struct dentry *dentry,
|
|
|
struct inode *dir,
|
|
|
struct dx_hash_info *hinfo,
|
|
|
struct dx_frame *frame,
|
|
|
int *err);
|
|
|
-static void dx_release (struct dx_frame *frames);
|
|
|
-static int dx_make_map (struct ext4_dir_entry_2 *de, int size,
|
|
|
- struct dx_hash_info *hinfo, struct dx_map_entry map[]);
|
|
|
+static void dx_release(struct dx_frame *frames);
|
|
|
+static int dx_make_map(struct ext4_dir_entry_2 *de, int size,
|
|
|
+ struct dx_hash_info *hinfo, struct dx_map_entry map[]);
|
|
|
static void dx_sort_map(struct dx_map_entry *map, unsigned count);
|
|
|
-static struct ext4_dir_entry_2 *dx_move_dirents (char *from, char *to,
|
|
|
+static struct ext4_dir_entry_2 *dx_move_dirents(char *from, char *to,
|
|
|
struct dx_map_entry *offsets, int count);
|
|
|
-static struct ext4_dir_entry_2* dx_pack_dirents (char *base, int size);
|
|
|
+static struct ext4_dir_entry_2* dx_pack_dirents(char *base, int size);
|
|
|
static void dx_insert_block(struct dx_frame *frame,
|
|
|
u32 hash, ext4_lblk_t block);
|
|
|
static int ext4_htree_next_block(struct inode *dir, __u32 hash,
|
|
@@ -207,44 +207,44 @@ static inline void dx_set_block(struct dx_entry *entry, ext4_lblk_t value)
|
|
|
entry->block = cpu_to_le32(value);
|
|
|
}
|
|
|
|
|
|
-static inline unsigned dx_get_hash (struct dx_entry *entry)
|
|
|
+static inline unsigned dx_get_hash(struct dx_entry *entry)
|
|
|
{
|
|
|
return le32_to_cpu(entry->hash);
|
|
|
}
|
|
|
|
|
|
-static inline void dx_set_hash (struct dx_entry *entry, unsigned value)
|
|
|
+static inline void dx_set_hash(struct dx_entry *entry, unsigned value)
|
|
|
{
|
|
|
entry->hash = cpu_to_le32(value);
|
|
|
}
|
|
|
|
|
|
-static inline unsigned dx_get_count (struct dx_entry *entries)
|
|
|
+static inline unsigned dx_get_count(struct dx_entry *entries)
|
|
|
{
|
|
|
return le16_to_cpu(((struct dx_countlimit *) entries)->count);
|
|
|
}
|
|
|
|
|
|
-static inline unsigned dx_get_limit (struct dx_entry *entries)
|
|
|
+static inline unsigned dx_get_limit(struct dx_entry *entries)
|
|
|
{
|
|
|
return le16_to_cpu(((struct dx_countlimit *) entries)->limit);
|
|
|
}
|
|
|
|
|
|
-static inline void dx_set_count (struct dx_entry *entries, unsigned value)
|
|
|
+static inline void dx_set_count(struct dx_entry *entries, unsigned value)
|
|
|
{
|
|
|
((struct dx_countlimit *) entries)->count = cpu_to_le16(value);
|
|
|
}
|
|
|
|
|
|
-static inline void dx_set_limit (struct dx_entry *entries, unsigned value)
|
|
|
+static inline void dx_set_limit(struct dx_entry *entries, unsigned value)
|
|
|
{
|
|
|
((struct dx_countlimit *) entries)->limit = cpu_to_le16(value);
|
|
|
}
|
|
|
|
|
|
-static inline unsigned dx_root_limit (struct inode *dir, unsigned infosize)
|
|
|
+static inline unsigned dx_root_limit(struct inode *dir, unsigned infosize)
|
|
|
{
|
|
|
unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(1) -
|
|
|
EXT4_DIR_REC_LEN(2) - infosize;
|
|
|
return entry_space / sizeof(struct dx_entry);
|
|
|
}
|
|
|
|
|
|
-static inline unsigned dx_node_limit (struct inode *dir)
|
|
|
+static inline unsigned dx_node_limit(struct inode *dir)
|
|
|
{
|
|
|
unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(0);
|
|
|
return entry_space / sizeof(struct dx_entry);
|
|
@@ -306,7 +306,7 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
|
|
|
struct dx_entry *entries, int levels)
|
|
|
{
|
|
|
unsigned blocksize = dir->i_sb->s_blocksize;
|
|
|
- unsigned count = dx_get_count (entries), names = 0, space = 0, i;
|
|
|
+ unsigned count = dx_get_count(entries), names = 0, space = 0, i;
|
|
|
unsigned bcount = 0;
|
|
|
struct buffer_head *bh;
|
|
|
int err;
|
|
@@ -325,7 +325,7 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
|
|
|
names += stats.names;
|
|
|
space += stats.space;
|
|
|
bcount += stats.bcount;
|
|
|
- brelse (bh);
|
|
|
+ brelse(bh);
|
|
|
}
|
|
|
if (bcount)
|
|
|
printk(KERN_DEBUG "%snames %u, fullness %u (%u%%)\n",
|
|
@@ -407,7 +407,7 @@ dx_probe(struct dentry *dentry, struct inode *dir,
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
- dxtrace (printk("Look up %x", hash));
|
|
|
+ dxtrace(printk("Look up %x", hash));
|
|
|
while (1)
|
|
|
{
|
|
|
count = dx_get_count(entries);
|
|
@@ -556,7 +556,7 @@ static int ext4_htree_next_block(struct inode *dir, __u32 hash,
|
|
|
0, &err)))
|
|
|
return err; /* Failure */
|
|
|
p++;
|
|
|
- brelse (p->bh);
|
|
|
+ brelse(p->bh);
|
|
|
p->bh = bh;
|
|
|
p->at = p->entries = ((struct dx_node *) bh->b_data)->entries;
|
|
|
}
|
|
@@ -594,7 +594,7 @@ static int htree_dirblock_to_tree(struct file *dir_file,
|
|
|
/* On error, skip the f_pos to the next block. */
|
|
|
dir_file->f_pos = (dir_file->f_pos |
|
|
|
(dir->i_sb->s_blocksize - 1)) + 1;
|
|
|
- brelse (bh);
|
|
|
+ brelse(bh);
|
|
|
return count;
|
|
|
}
|
|
|
ext4fs_dirhash(de->name, de->name_len, hinfo);
|
|
@@ -803,7 +803,7 @@ static inline int ext4_match (int len, const char * const name,
|
|
|
/*
|
|
|
* Returns 0 if not found, -1 on failure, and 1 on success
|
|
|
*/
|
|
|
-static inline int search_dirblock(struct buffer_head * bh,
|
|
|
+static inline int search_dirblock(struct buffer_head *bh,
|
|
|
struct inode *dir,
|
|
|
struct dentry *dentry,
|
|
|
unsigned long offset,
|
|
@@ -855,9 +855,9 @@ static inline int search_dirblock(struct buffer_head * bh,
|
|
|
static struct buffer_head * ext4_find_entry (struct dentry *dentry,
|
|
|
struct ext4_dir_entry_2 ** res_dir)
|
|
|
{
|
|
|
- struct super_block * sb;
|
|
|
- struct buffer_head * bh_use[NAMEI_RA_SIZE];
|
|
|
- struct buffer_head * bh, *ret = NULL;
|
|
|
+ struct super_block *sb;
|
|
|
+ struct buffer_head *bh_use[NAMEI_RA_SIZE];
|
|
|
+ struct buffer_head *bh, *ret = NULL;
|
|
|
ext4_lblk_t start, block, b;
|
|
|
int ra_max = 0; /* Number of bh's in the readahead
|
|
|
buffer, bh_use[] */
|
|
@@ -958,7 +958,7 @@ restart:
|
|
|
cleanup_and_exit:
|
|
|
/* Clean up the read-ahead blocks */
|
|
|
for (; ra_ptr < ra_max; ra_ptr++)
|
|
|
- brelse (bh_use[ra_ptr]);
|
|
|
+ brelse(bh_use[ra_ptr]);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
@@ -1012,7 +1012,7 @@ static struct buffer_head * ext4_dx_find_entry(struct dentry *dentry,
|
|
|
return bh;
|
|
|
}
|
|
|
}
|
|
|
- brelse (bh);
|
|
|
+ brelse(bh);
|
|
|
/* Check to see if we should continue to search */
|
|
|
retval = ext4_htree_next_block(dir, hash, frame,
|
|
|
frames, NULL);
|
|
@@ -1032,11 +1032,11 @@ errout:
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
-static struct dentry *ext4_lookup(struct inode * dir, struct dentry *dentry, struct nameidata *nd)
|
|
|
+static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
|
|
|
{
|
|
|
- struct inode * inode;
|
|
|
- struct ext4_dir_entry_2 * de;
|
|
|
- struct buffer_head * bh;
|
|
|
+ struct inode *inode;
|
|
|
+ struct ext4_dir_entry_2 *de;
|
|
|
+ struct buffer_head *bh;
|
|
|
|
|
|
if (dentry->d_name.len > EXT4_NAME_LEN)
|
|
|
return ERR_PTR(-ENAMETOOLONG);
|
|
@@ -1045,7 +1045,7 @@ static struct dentry *ext4_lookup(struct inode * dir, struct dentry *dentry, str
|
|
|
inode = NULL;
|
|
|
if (bh) {
|
|
|
unsigned long ino = le32_to_cpu(de->inode);
|
|
|
- brelse (bh);
|
|
|
+ brelse(bh);
|
|
|
if (!ext4_valid_inum(dir->i_sb, ino)) {
|
|
|
ext4_error(dir->i_sb, "ext4_lookup",
|
|
|
"bad inode number: %lu", ino);
|
|
@@ -1203,10 +1203,10 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
|
|
|
|
|
|
/* create map in the end of data2 block */
|
|
|
map = (struct dx_map_entry *) (data2 + blocksize);
|
|
|
- count = dx_make_map ((struct ext4_dir_entry_2 *) data1,
|
|
|
+ count = dx_make_map((struct ext4_dir_entry_2 *) data1,
|
|
|
blocksize, hinfo, map);
|
|
|
map -= count;
|
|
|
- dx_sort_map (map, count);
|
|
|
+ dx_sort_map(map, count);
|
|
|
/* Split the existing block in the middle, size-wise */
|
|
|
size = 0;
|
|
|
move = 0;
|
|
@@ -1227,7 +1227,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
|
|
|
|
|
|
/* Fancy dance to stay within two buffers */
|
|
|
de2 = dx_move_dirents(data1, data2, map + split, count - split);
|
|
|
- de = dx_pack_dirents(data1,blocksize);
|
|
|
+ de = dx_pack_dirents(data1, blocksize);
|
|
|
de->rec_len = ext4_rec_len_to_disk(data1 + blocksize - (char *) de);
|
|
|
de2->rec_len = ext4_rec_len_to_disk(data2 + blocksize - (char *) de2);
|
|
|
dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data1, blocksize, 1));
|
|
@@ -1239,15 +1239,15 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
|
|
|
swap(*bh, bh2);
|
|
|
de = de2;
|
|
|
}
|
|
|
- dx_insert_block (frame, hash2 + continued, newblock);
|
|
|
- err = ext4_journal_dirty_metadata (handle, bh2);
|
|
|
+ dx_insert_block(frame, hash2 + continued, newblock);
|
|
|
+ err = ext4_journal_dirty_metadata(handle, bh2);
|
|
|
if (err)
|
|
|
goto journal_error;
|
|
|
- err = ext4_journal_dirty_metadata (handle, frame->bh);
|
|
|
+ err = ext4_journal_dirty_metadata(handle, frame->bh);
|
|
|
if (err)
|
|
|
goto journal_error;
|
|
|
- brelse (bh2);
|
|
|
- dxtrace(dx_show_index ("frame", frame->entries));
|
|
|
+ brelse(bh2);
|
|
|
+ dxtrace(dx_show_index("frame", frame->entries));
|
|
|
return de;
|
|
|
|
|
|
journal_error:
|
|
@@ -1273,7 +1273,7 @@ errout:
|
|
|
*/
|
|
|
static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,
|
|
|
struct inode *inode, struct ext4_dir_entry_2 *de,
|
|
|
- struct buffer_head * bh)
|
|
|
+ struct buffer_head *bh)
|
|
|
{
|
|
|
struct inode *dir = dentry->d_parent->d_inode;
|
|
|
const char *name = dentry->d_name.name;
|
|
@@ -1290,11 +1290,11 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,
|
|
|
while ((char *) de <= top) {
|
|
|
if (!ext4_check_dir_entry("ext4_add_entry", dir, de,
|
|
|
bh, offset)) {
|
|
|
- brelse (bh);
|
|
|
+ brelse(bh);
|
|
|
return -EIO;
|
|
|
}
|
|
|
- if (ext4_match (namelen, name, de)) {
|
|
|
- brelse (bh);
|
|
|
+ if (ext4_match(namelen, name, de)) {
|
|
|
+ brelse(bh);
|
|
|
return -EEXIST;
|
|
|
}
|
|
|
nlen = EXT4_DIR_REC_LEN(de->name_len);
|
|
@@ -1331,7 +1331,7 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,
|
|
|
} else
|
|
|
de->inode = 0;
|
|
|
de->name_len = namelen;
|
|
|
- memcpy (de->name, name, namelen);
|
|
|
+ memcpy(de->name, name, namelen);
|
|
|
/*
|
|
|
* XXX shouldn't update any times until successful
|
|
|
* completion of syscall, but too many callers depend
|
|
@@ -1388,7 +1388,7 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
|
|
|
}
|
|
|
root = (struct dx_root *) bh->b_data;
|
|
|
|
|
|
- bh2 = ext4_append (handle, dir, &block, &retval);
|
|
|
+ bh2 = ext4_append(handle, dir, &block, &retval);
|
|
|
if (!(bh2)) {
|
|
|
brelse(bh);
|
|
|
return retval;
|
|
@@ -1414,9 +1414,9 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
|
|
|
root->info.info_length = sizeof(root->info);
|
|
|
root->info.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
|
|
|
entries = root->entries;
|
|
|
- dx_set_block (entries, 1);
|
|
|
- dx_set_count (entries, 1);
|
|
|
- dx_set_limit (entries, dx_root_limit(dir, sizeof(root->info)));
|
|
|
+ dx_set_block(entries, 1);
|
|
|
+ dx_set_count(entries, 1);
|
|
|
+ dx_set_limit(entries, dx_root_limit(dir, sizeof(root->info)));
|
|
|
|
|
|
/* Initialize as for dx_probe */
|
|
|
hinfo.hash_version = root->info.hash_version;
|
|
@@ -1445,14 +1445,14 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
|
|
|
* may not sleep between calling this and putting something into
|
|
|
* the entry, as someone else might have used it while you slept.
|
|
|
*/
|
|
|
-static int ext4_add_entry (handle_t *handle, struct dentry *dentry,
|
|
|
- struct inode *inode)
|
|
|
+static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
|
|
|
+ struct inode *inode)
|
|
|
{
|
|
|
struct inode *dir = dentry->d_parent->d_inode;
|
|
|
unsigned long offset;
|
|
|
- struct buffer_head * bh;
|
|
|
+ struct buffer_head *bh;
|
|
|
struct ext4_dir_entry_2 *de;
|
|
|
- struct super_block * sb;
|
|
|
+ struct super_block *sb;
|
|
|
int retval;
|
|
|
int dx_fallback=0;
|
|
|
unsigned blocksize;
|
|
@@ -1502,9 +1502,9 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
|
|
|
struct dx_frame frames[2], *frame;
|
|
|
struct dx_entry *entries, *at;
|
|
|
struct dx_hash_info hinfo;
|
|
|
- struct buffer_head * bh;
|
|
|
+ struct buffer_head *bh;
|
|
|
struct inode *dir = dentry->d_parent->d_inode;
|
|
|
- struct super_block * sb = dir->i_sb;
|
|
|
+ struct super_block *sb = dir->i_sb;
|
|
|
struct ext4_dir_entry_2 *de;
|
|
|
int err;
|
|
|
|
|
@@ -1570,11 +1570,11 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
|
|
|
if (err)
|
|
|
goto journal_error;
|
|
|
|
|
|
- memcpy ((char *) entries2, (char *) (entries + icount1),
|
|
|
- icount2 * sizeof(struct dx_entry));
|
|
|
- dx_set_count (entries, icount1);
|
|
|
- dx_set_count (entries2, icount2);
|
|
|
- dx_set_limit (entries2, dx_node_limit(dir));
|
|
|
+ memcpy((char *) entries2, (char *) (entries + icount1),
|
|
|
+ icount2 * sizeof(struct dx_entry));
|
|
|
+ dx_set_count(entries, icount1);
|
|
|
+ dx_set_count(entries2, icount2);
|
|
|
+ dx_set_limit(entries2, dx_node_limit(dir));
|
|
|
|
|
|
/* Which index block gets the new entry? */
|
|
|
if (at - entries >= icount1) {
|
|
@@ -1582,9 +1582,9 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
|
|
|
frame->entries = entries = entries2;
|
|
|
swap(frame->bh, bh2);
|
|
|
}
|
|
|
- dx_insert_block (frames + 0, hash2, newblock);
|
|
|
- dxtrace(dx_show_index ("node", frames[1].entries));
|
|
|
- dxtrace(dx_show_index ("node",
|
|
|
+ dx_insert_block(frames + 0, hash2, newblock);
|
|
|
+ dxtrace(dx_show_index("node", frames[1].entries));
|
|
|
+ dxtrace(dx_show_index("node",
|
|
|
((struct dx_node *) bh2->b_data)->entries));
|
|
|
err = ext4_journal_dirty_metadata(handle, bh2);
|
|
|
if (err)
|
|
@@ -1634,12 +1634,12 @@ cleanup:
|
|
|
* ext4_delete_entry deletes a directory entry by merging it with the
|
|
|
* previous entry
|
|
|
*/
|
|
|
-static int ext4_delete_entry (handle_t *handle,
|
|
|
- struct inode * dir,
|
|
|
- struct ext4_dir_entry_2 * de_del,
|
|
|
- struct buffer_head * bh)
|
|
|
+static int ext4_delete_entry(handle_t *handle,
|
|
|
+ struct inode *dir,
|
|
|
+ struct ext4_dir_entry_2 *de_del,
|
|
|
+ struct buffer_head *bh)
|
|
|
{
|
|
|
- struct ext4_dir_entry_2 * de, * pde;
|
|
|
+ struct ext4_dir_entry_2 *de, *pde;
|
|
|
int i;
|
|
|
|
|
|
i = 0;
|
|
@@ -1720,11 +1720,11 @@ static int ext4_add_nondir(handle_t *handle,
|
|
|
* If the create succeeds, we fill in the inode information
|
|
|
* with d_instantiate().
|
|
|
*/
|
|
|
-static int ext4_create (struct inode * dir, struct dentry * dentry, int mode,
|
|
|
- struct nameidata *nd)
|
|
|
+static int ext4_create(struct inode *dir, struct dentry *dentry, int mode,
|
|
|
+ struct nameidata *nd)
|
|
|
{
|
|
|
handle_t *handle;
|
|
|
- struct inode * inode;
|
|
|
+ struct inode *inode;
|
|
|
int err, retries = 0;
|
|
|
|
|
|
retry:
|
|
@@ -1751,8 +1751,8 @@ retry:
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static int ext4_mknod (struct inode * dir, struct dentry *dentry,
|
|
|
- int mode, dev_t rdev)
|
|
|
+static int ext4_mknod(struct inode *dir, struct dentry *dentry,
|
|
|
+ int mode, dev_t rdev)
|
|
|
{
|
|
|
handle_t *handle;
|
|
|
struct inode *inode;
|
|
@@ -1771,7 +1771,7 @@ retry:
|
|
|
if (IS_DIRSYNC(dir))
|
|
|
handle->h_sync = 1;
|
|
|
|
|
|
- inode = ext4_new_inode (handle, dir, mode);
|
|
|
+ inode = ext4_new_inode(handle, dir, mode);
|
|
|
err = PTR_ERR(inode);
|
|
|
if (!IS_ERR(inode)) {
|
|
|
init_special_inode(inode, inode->i_mode, rdev);
|
|
@@ -1786,12 +1786,12 @@ retry:
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static int ext4_mkdir(struct inode * dir, struct dentry * dentry, int mode)
|
|
|
+static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
|
|
|
{
|
|
|
handle_t *handle;
|
|
|
- struct inode * inode;
|
|
|
- struct buffer_head * dir_block;
|
|
|
- struct ext4_dir_entry_2 * de;
|
|
|
+ struct inode *inode;
|
|
|
+ struct buffer_head *dir_block;
|
|
|
+ struct ext4_dir_entry_2 *de;
|
|
|
int err, retries = 0;
|
|
|
|
|
|
if (EXT4_DIR_LINK_MAX(dir))
|
|
@@ -1807,7 +1807,7 @@ retry:
|
|
|
if (IS_DIRSYNC(dir))
|
|
|
handle->h_sync = 1;
|
|
|
|
|
|
- inode = ext4_new_inode (handle, dir, S_IFDIR | mode);
|
|
|
+ inode = ext4_new_inode(handle, dir, S_IFDIR | mode);
|
|
|
err = PTR_ERR(inode);
|
|
|
if (IS_ERR(inode))
|
|
|
goto out_stop;
|
|
@@ -1815,7 +1815,7 @@ retry:
|
|
|
inode->i_op = &ext4_dir_inode_operations;
|
|
|
inode->i_fop = &ext4_dir_operations;
|
|
|
inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
|
|
|
- dir_block = ext4_bread (handle, inode, 0, 1, &err);
|
|
|
+ dir_block = ext4_bread(handle, inode, 0, 1, &err);
|
|
|
if (!dir_block)
|
|
|
goto out_clear_inode;
|
|
|
BUFFER_TRACE(dir_block, "get_write_access");
|
|
@@ -1824,26 +1824,26 @@ retry:
|
|
|
de->inode = cpu_to_le32(inode->i_ino);
|
|
|
de->name_len = 1;
|
|
|
de->rec_len = ext4_rec_len_to_disk(EXT4_DIR_REC_LEN(de->name_len));
|
|
|
- strcpy (de->name, ".");
|
|
|
+ strcpy(de->name, ".");
|
|
|
ext4_set_de_type(dir->i_sb, de, S_IFDIR);
|
|
|
de = ext4_next_entry(de);
|
|
|
de->inode = cpu_to_le32(dir->i_ino);
|
|
|
de->rec_len = ext4_rec_len_to_disk(inode->i_sb->s_blocksize -
|
|
|
EXT4_DIR_REC_LEN(1));
|
|
|
de->name_len = 2;
|
|
|
- strcpy (de->name, "..");
|
|
|
+ strcpy(de->name, "..");
|
|
|
ext4_set_de_type(dir->i_sb, de, S_IFDIR);
|
|
|
inode->i_nlink = 2;
|
|
|
BUFFER_TRACE(dir_block, "call ext4_journal_dirty_metadata");
|
|
|
ext4_journal_dirty_metadata(handle, dir_block);
|
|
|
- brelse (dir_block);
|
|
|
+ brelse(dir_block);
|
|
|
ext4_mark_inode_dirty(handle, inode);
|
|
|
- err = ext4_add_entry (handle, dentry, inode);
|
|
|
+ err = ext4_add_entry(handle, dentry, inode);
|
|
|
if (err) {
|
|
|
out_clear_inode:
|
|
|
clear_nlink(inode);
|
|
|
ext4_mark_inode_dirty(handle, inode);
|
|
|
- iput (inode);
|
|
|
+ iput(inode);
|
|
|
goto out_stop;
|
|
|
}
|
|
|
ext4_inc_count(handle, dir);
|
|
@@ -1860,17 +1860,17 @@ out_stop:
|
|
|
/*
|
|
|
* routine to check that the specified directory is empty (for rmdir)
|
|
|
*/
|
|
|
-static int empty_dir (struct inode * inode)
|
|
|
+static int empty_dir(struct inode *inode)
|
|
|
{
|
|
|
unsigned long offset;
|
|
|
- struct buffer_head * bh;
|
|
|
- struct ext4_dir_entry_2 * de, * de1;
|
|
|
- struct super_block * sb;
|
|
|
+ struct buffer_head *bh;
|
|
|
+ struct ext4_dir_entry_2 *de, *de1;
|
|
|
+ struct super_block *sb;
|
|
|
int err = 0;
|
|
|
|
|
|
sb = inode->i_sb;
|
|
|
if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2) ||
|
|
|
- !(bh = ext4_bread (NULL, inode, 0, 0, &err))) {
|
|
|
+ !(bh = ext4_bread(NULL, inode, 0, 0, &err))) {
|
|
|
if (err)
|
|
|
ext4_error(inode->i_sb, __func__,
|
|
|
"error %d reading directory #%lu offset 0",
|
|
@@ -1885,23 +1885,23 @@ static int empty_dir (struct inode * inode)
|
|
|
de1 = ext4_next_entry(de);
|
|
|
if (le32_to_cpu(de->inode) != inode->i_ino ||
|
|
|
!le32_to_cpu(de1->inode) ||
|
|
|
- strcmp (".", de->name) ||
|
|
|
- strcmp ("..", de1->name)) {
|
|
|
- ext4_warning (inode->i_sb, "empty_dir",
|
|
|
- "bad directory (dir #%lu) - no `.' or `..'",
|
|
|
- inode->i_ino);
|
|
|
- brelse (bh);
|
|
|
+ strcmp(".", de->name) ||
|
|
|
+ strcmp("..", de1->name)) {
|
|
|
+ ext4_warning(inode->i_sb, "empty_dir",
|
|
|
+ "bad directory (dir #%lu) - no `.' or `..'",
|
|
|
+ inode->i_ino);
|
|
|
+ brelse(bh);
|
|
|
return 1;
|
|
|
}
|
|
|
offset = ext4_rec_len_from_disk(de->rec_len) +
|
|
|
ext4_rec_len_from_disk(de1->rec_len);
|
|
|
de = ext4_next_entry(de1);
|
|
|
- while (offset < inode->i_size ) {
|
|
|
+ while (offset < inode->i_size) {
|
|
|
if (!bh ||
|
|
|
(void *) de >= (void *) (bh->b_data+sb->s_blocksize)) {
|
|
|
err = 0;
|
|
|
- brelse (bh);
|
|
|
- bh = ext4_bread (NULL, inode,
|
|
|
+ brelse(bh);
|
|
|
+ bh = ext4_bread(NULL, inode,
|
|
|
offset >> EXT4_BLOCK_SIZE_BITS(sb), 0, &err);
|
|
|
if (!bh) {
|
|
|
if (err)
|
|
@@ -1921,13 +1921,13 @@ static int empty_dir (struct inode * inode)
|
|
|
continue;
|
|
|
}
|
|
|
if (le32_to_cpu(de->inode)) {
|
|
|
- brelse (bh);
|
|
|
+ brelse(bh);
|
|
|
return 0;
|
|
|
}
|
|
|
offset += ext4_rec_len_from_disk(de->rec_len);
|
|
|
de = ext4_next_entry(de);
|
|
|
}
|
|
|
- brelse (bh);
|
|
|
+ brelse(bh);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -1958,8 +1958,8 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
|
|
|
* ->i_nlink. For, say it, character device. Not a regular file,
|
|
|
* not a directory, not a symlink and ->i_nlink > 0.
|
|
|
*/
|
|
|
- J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
|
|
|
- S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
|
|
|
+ J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
|
|
|
+ S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
|
|
|
|
|
|
BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get_write_access");
|
|
|
err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
|
|
@@ -2073,12 +2073,12 @@ out_brelse:
|
|
|
goto out_err;
|
|
|
}
|
|
|
|
|
|
-static int ext4_rmdir (struct inode * dir, struct dentry *dentry)
|
|
|
+static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
|
|
|
{
|
|
|
int retval;
|
|
|
- struct inode * inode;
|
|
|
- struct buffer_head * bh;
|
|
|
- struct ext4_dir_entry_2 * de;
|
|
|
+ struct inode *inode;
|
|
|
+ struct buffer_head *bh;
|
|
|
+ struct ext4_dir_entry_2 *de;
|
|
|
handle_t *handle;
|
|
|
|
|
|
/* Initialize quotas before so that eventual writes go in
|
|
@@ -2089,7 +2089,7 @@ static int ext4_rmdir (struct inode * dir, struct dentry *dentry)
|
|
|
return PTR_ERR(handle);
|
|
|
|
|
|
retval = -ENOENT;
|
|
|
- bh = ext4_find_entry (dentry, &de);
|
|
|
+ bh = ext4_find_entry(dentry, &de);
|
|
|
if (!bh)
|
|
|
goto end_rmdir;
|
|
|
|
|
@@ -2103,16 +2103,16 @@ static int ext4_rmdir (struct inode * dir, struct dentry *dentry)
|
|
|
goto end_rmdir;
|
|
|
|
|
|
retval = -ENOTEMPTY;
|
|
|
- if (!empty_dir (inode))
|
|
|
+ if (!empty_dir(inode))
|
|
|
goto end_rmdir;
|
|
|
|
|
|
retval = ext4_delete_entry(handle, dir, de, bh);
|
|
|
if (retval)
|
|
|
goto end_rmdir;
|
|
|
if (!EXT4_DIR_LINK_EMPTY(inode))
|
|
|
- ext4_warning (inode->i_sb, "ext4_rmdir",
|
|
|
- "empty directory has too many links (%d)",
|
|
|
- inode->i_nlink);
|
|
|
+ ext4_warning(inode->i_sb, "ext4_rmdir",
|
|
|
+ "empty directory has too many links (%d)",
|
|
|
+ inode->i_nlink);
|
|
|
inode->i_version++;
|
|
|
clear_nlink(inode);
|
|
|
/* There's no need to set i_disksize: the fact that i_nlink is
|
|
@@ -2128,16 +2128,16 @@ static int ext4_rmdir (struct inode * dir, struct dentry *dentry)
|
|
|
|
|
|
end_rmdir:
|
|
|
ext4_journal_stop(handle);
|
|
|
- brelse (bh);
|
|
|
+ brelse(bh);
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
-static int ext4_unlink(struct inode * dir, struct dentry *dentry)
|
|
|
+static int ext4_unlink(struct inode *dir, struct dentry *dentry)
|
|
|
{
|
|
|
int retval;
|
|
|
- struct inode * inode;
|
|
|
- struct buffer_head * bh;
|
|
|
- struct ext4_dir_entry_2 * de;
|
|
|
+ struct inode *inode;
|
|
|
+ struct buffer_head *bh;
|
|
|
+ struct ext4_dir_entry_2 *de;
|
|
|
handle_t *handle;
|
|
|
|
|
|
/* Initialize quotas before so that eventual writes go
|
|
@@ -2151,7 +2151,7 @@ static int ext4_unlink(struct inode * dir, struct dentry *dentry)
|
|
|
handle->h_sync = 1;
|
|
|
|
|
|
retval = -ENOENT;
|
|
|
- bh = ext4_find_entry (dentry, &de);
|
|
|
+ bh = ext4_find_entry(dentry, &de);
|
|
|
if (!bh)
|
|
|
goto end_unlink;
|
|
|
|
|
@@ -2162,9 +2162,9 @@ static int ext4_unlink(struct inode * dir, struct dentry *dentry)
|
|
|
goto end_unlink;
|
|
|
|
|
|
if (!inode->i_nlink) {
|
|
|
- ext4_warning (inode->i_sb, "ext4_unlink",
|
|
|
- "Deleting nonexistent file (%lu), %d",
|
|
|
- inode->i_ino, inode->i_nlink);
|
|
|
+ ext4_warning(inode->i_sb, "ext4_unlink",
|
|
|
+ "Deleting nonexistent file (%lu), %d",
|
|
|
+ inode->i_ino, inode->i_nlink);
|
|
|
inode->i_nlink = 1;
|
|
|
}
|
|
|
retval = ext4_delete_entry(handle, dir, de, bh);
|
|
@@ -2182,15 +2182,15 @@ static int ext4_unlink(struct inode * dir, struct dentry *dentry)
|
|
|
|
|
|
end_unlink:
|
|
|
ext4_journal_stop(handle);
|
|
|
- brelse (bh);
|
|
|
+ brelse(bh);
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
-static int ext4_symlink (struct inode * dir,
|
|
|
- struct dentry *dentry, const char * symname)
|
|
|
+static int ext4_symlink(struct inode *dir,
|
|
|
+ struct dentry *dentry, const char *symname)
|
|
|
{
|
|
|
handle_t *handle;
|
|
|
- struct inode * inode;
|
|
|
+ struct inode *inode;
|
|
|
int l, err, retries = 0;
|
|
|
|
|
|
l = strlen(symname)+1;
|
|
@@ -2207,12 +2207,12 @@ retry:
|
|
|
if (IS_DIRSYNC(dir))
|
|
|
handle->h_sync = 1;
|
|
|
|
|
|
- inode = ext4_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
|
|
|
+ inode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO);
|
|
|
err = PTR_ERR(inode);
|
|
|
if (IS_ERR(inode))
|
|
|
goto out_stop;
|
|
|
|
|
|
- if (l > sizeof (EXT4_I(inode)->i_data)) {
|
|
|
+ if (l > sizeof(EXT4_I(inode)->i_data)) {
|
|
|
inode->i_op = &ext4_symlink_inode_operations;
|
|
|
ext4_set_aops(inode);
|
|
|
/*
|
|
@@ -2225,14 +2225,14 @@ retry:
|
|
|
if (err) {
|
|
|
clear_nlink(inode);
|
|
|
ext4_mark_inode_dirty(handle, inode);
|
|
|
- iput (inode);
|
|
|
+ iput(inode);
|
|
|
goto out_stop;
|
|
|
}
|
|
|
} else {
|
|
|
/* clear the extent format for fast symlink */
|
|
|
EXT4_I(inode)->i_flags &= ~EXT4_EXTENTS_FL;
|
|
|
inode->i_op = &ext4_fast_symlink_inode_operations;
|
|
|
- memcpy((char*)&EXT4_I(inode)->i_data,symname,l);
|
|
|
+ memcpy((char *)&EXT4_I(inode)->i_data, symname, l);
|
|
|
inode->i_size = l-1;
|
|
|
}
|
|
|
EXT4_I(inode)->i_disksize = inode->i_size;
|
|
@@ -2244,8 +2244,8 @@ out_stop:
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static int ext4_link (struct dentry * old_dentry,
|
|
|
- struct inode * dir, struct dentry *dentry)
|
|
|
+static int ext4_link(struct dentry *old_dentry,
|
|
|
+ struct inode *dir, struct dentry *dentry)
|
|
|
{
|
|
|
handle_t *handle;
|
|
|
struct inode *inode = old_dentry->d_inode;
|
|
@@ -2288,13 +2288,13 @@ retry:
|
|
|
* Anybody can rename anything with this: the permission checks are left to the
|
|
|
* higher-level routines.
|
|
|
*/
|
|
|
-static int ext4_rename (struct inode * old_dir, struct dentry *old_dentry,
|
|
|
- struct inode * new_dir,struct dentry *new_dentry)
|
|
|
+static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|
|
+ struct inode *new_dir, struct dentry *new_dentry)
|
|
|
{
|
|
|
handle_t *handle;
|
|
|
- struct inode * old_inode, * new_inode;
|
|
|
- struct buffer_head * old_bh, * new_bh, * dir_bh;
|
|
|
- struct ext4_dir_entry_2 * old_de, * new_de;
|
|
|
+ struct inode *old_inode, *new_inode;
|
|
|
+ struct buffer_head *old_bh, *new_bh, *dir_bh;
|
|
|
+ struct ext4_dir_entry_2 *old_de, *new_de;
|
|
|
int retval;
|
|
|
|
|
|
old_bh = new_bh = dir_bh = NULL;
|
|
@@ -2312,7 +2312,7 @@ static int ext4_rename (struct inode * old_dir, struct dentry *old_dentry,
|
|
|
if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir))
|
|
|
handle->h_sync = 1;
|
|
|
|
|
|
- old_bh = ext4_find_entry (old_dentry, &old_de);
|
|
|
+ old_bh = ext4_find_entry(old_dentry, &old_de);
|
|
|
/*
|
|
|
* Check for inode number is _not_ due to possible IO errors.
|
|
|
* We might rmdir the source, keep it as pwd of some process
|
|
@@ -2325,32 +2325,32 @@ static int ext4_rename (struct inode * old_dir, struct dentry *old_dentry,
|
|
|
goto end_rename;
|
|
|
|
|
|
new_inode = new_dentry->d_inode;
|
|
|
- new_bh = ext4_find_entry (new_dentry, &new_de);
|
|
|
+ new_bh = ext4_find_entry(new_dentry, &new_de);
|
|
|
if (new_bh) {
|
|
|
if (!new_inode) {
|
|
|
- brelse (new_bh);
|
|
|
+ brelse(new_bh);
|
|
|
new_bh = NULL;
|
|
|
}
|
|
|
}
|
|
|
if (S_ISDIR(old_inode->i_mode)) {
|
|
|
if (new_inode) {
|
|
|
retval = -ENOTEMPTY;
|
|
|
- if (!empty_dir (new_inode))
|
|
|
+ if (!empty_dir(new_inode))
|
|
|
goto end_rename;
|
|
|
}
|
|
|
retval = -EIO;
|
|
|
- dir_bh = ext4_bread (handle, old_inode, 0, 0, &retval);
|
|
|
+ dir_bh = ext4_bread(handle, old_inode, 0, 0, &retval);
|
|
|
if (!dir_bh)
|
|
|
goto end_rename;
|
|
|
if (le32_to_cpu(PARENT_INO(dir_bh->b_data)) != old_dir->i_ino)
|
|
|
goto end_rename;
|
|
|
retval = -EMLINK;
|
|
|
- if (!new_inode && new_dir!=old_dir &&
|
|
|
+ if (!new_inode && new_dir != old_dir &&
|
|
|
new_dir->i_nlink >= EXT4_LINK_MAX)
|
|
|
goto end_rename;
|
|
|
}
|
|
|
if (!new_bh) {
|
|
|
- retval = ext4_add_entry (handle, new_dentry, old_inode);
|
|
|
+ retval = ext4_add_entry(handle, new_dentry, old_inode);
|
|
|
if (retval)
|
|
|
goto end_rename;
|
|
|
} else {
|
|
@@ -2437,9 +2437,9 @@ static int ext4_rename (struct inode * old_dir, struct dentry *old_dentry,
|
|
|
retval = 0;
|
|
|
|
|
|
end_rename:
|
|
|
- brelse (dir_bh);
|
|
|
- brelse (old_bh);
|
|
|
- brelse (new_bh);
|
|
|
+ brelse(dir_bh);
|
|
|
+ brelse(old_bh);
|
|
|
+ brelse(new_bh);
|
|
|
ext4_journal_stop(handle);
|
|
|
return retval;
|
|
|
}
|