Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 67730
b: refs/heads/master
c: 38760e2
h: refs/heads/master
v: v3
  • Loading branch information
Mark Fasheh committed Oct 12, 2007
1 parent fbfb8c8 commit c2b4a8e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: be94d11704ef79030fd2e6a0c41b4a7f65f9e860
refs/heads/master: 38760e243249f03b4c6d78ca624dd846a2681b67
22 changes: 22 additions & 0 deletions trunk/fs/ocfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,28 @@ struct buffer_head *ocfs2_find_entry(const char *name, int namelen,
return ret;
}

int ocfs2_update_entry(struct inode *dir, handle_t *handle,
struct buffer_head *de_bh, struct ocfs2_dir_entry *de,
struct inode *new_entry_inode)
{
int ret;

ret = ocfs2_journal_access(handle, dir, de_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
if (ret) {
mlog_errno(ret);
goto out;
}

de->inode = cpu_to_le64(OCFS2_I(new_entry_inode)->ip_blkno);
ocfs2_set_de_type(de, new_entry_inode->i_mode);

ocfs2_journal_dirty(handle, de_bh);

out:
return ret;
}

/*
* ocfs2_delete_entry deletes a directory entry by merging it with the
* previous entry
Expand Down
3 changes: 3 additions & 0 deletions trunk/fs/ocfs2/dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ static inline int ocfs2_add_entry(handle_t *handle,
dentry->d_name.name, dentry->d_name.len,
inode, blkno, parent_fe_bh, insert_bh);
}
int ocfs2_update_entry(struct inode *dir, handle_t *handle,
struct buffer_head *de_bh, struct ocfs2_dir_entry *de,
struct inode *new_entry_inode);

int ocfs2_check_dir_for_entry(struct inode *dir,
const char *name,
Expand Down
53 changes: 22 additions & 31 deletions trunk/fs/ocfs2/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,11 +933,6 @@ static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2)
ocfs2_meta_unlock(inode2, 1);
}

#define PARENT_INO(buffer) \
((struct ocfs2_dir_entry *) \
((char *)buffer + \
le16_to_cpu(((struct ocfs2_dir_entry *)buffer)->rec_len)))->inode

static int ocfs2_rename(struct inode *old_dir,
struct dentry *old_dentry,
struct inode *new_dir,
Expand All @@ -959,8 +954,8 @@ static int ocfs2_rename(struct inode *old_dir,
handle_t *handle = NULL;
struct buffer_head *old_dir_bh = NULL;
struct buffer_head *new_dir_bh = NULL;
struct ocfs2_dir_entry *old_de = NULL, *new_de = NULL; // dirent for old_dentry
// and new_dentry
struct ocfs2_dir_entry *old_inode_dot_dot_de = NULL, *old_de = NULL,
*new_de = NULL;
struct buffer_head *new_de_bh = NULL, *old_de_bh = NULL; // bhs for above
struct buffer_head *old_inode_de_bh = NULL; // if old_dentry is a dir,
// this is the 1st dirent bh
Expand Down Expand Up @@ -1044,19 +1039,26 @@ static int ocfs2_rename(struct inode *old_dir,
}

if (S_ISDIR(old_inode->i_mode)) {
status = -EIO;
old_inode_de_bh = ocfs2_bread(old_inode, 0, &status, 0);
if (!old_inode_de_bh)
u64 old_inode_parent;

status = ocfs2_find_files_on_disk("..", 2, &old_inode_parent,
old_inode, &old_inode_de_bh,
&old_inode_dot_dot_de);
if (status) {
status = -EIO;
goto bail;
}

status = -EIO;
if (le64_to_cpu(PARENT_INO(old_inode_de_bh->b_data)) !=
OCFS2_I(old_dir)->ip_blkno)
if (old_inode_parent != OCFS2_I(old_dir)->ip_blkno) {
status = -EIO;
goto bail;
status = -EMLINK;
if (!new_inode && new_dir!=old_dir &&
new_dir->i_nlink >= OCFS2_LINK_MAX)
}

if (!new_inode && new_dir != old_dir &&
new_dir->i_nlink >= OCFS2_LINK_MAX) {
status = -EMLINK;
goto bail;
}
}

status = -ENOENT;
Expand Down Expand Up @@ -1206,20 +1208,13 @@ static int ocfs2_rename(struct inode *old_dir,
}

/* change the dirent to point to the correct inode */
status = ocfs2_journal_access(handle, new_dir, new_de_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
status = ocfs2_update_entry(new_dir, handle, new_de_bh,
new_de, old_inode);
if (status < 0) {
mlog_errno(status);
goto bail;
}
new_de->inode = cpu_to_le64(OCFS2_I(old_inode)->ip_blkno);
new_de->file_type = old_de->file_type;
new_dir->i_version++;
status = ocfs2_journal_dirty(handle, new_de_bh);
if (status < 0) {
mlog_errno(status);
goto bail;
}

if (S_ISDIR(new_inode->i_mode))
newfe->i_links_count = 0;
Expand Down Expand Up @@ -1268,12 +1263,8 @@ static int ocfs2_rename(struct inode *old_dir,
}
old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
if (old_inode_de_bh) {
status = ocfs2_journal_access(handle, old_inode,
old_inode_de_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
PARENT_INO(old_inode_de_bh->b_data) =
cpu_to_le64(OCFS2_I(new_dir)->ip_blkno);
status = ocfs2_journal_dirty(handle, old_inode_de_bh);
status = ocfs2_update_entry(old_inode, handle, old_inode_de_bh,
old_inode_dot_dot_de, new_dir);
old_dir->i_nlink--;
if (new_inode) {
new_inode->i_nlink--;
Expand Down

0 comments on commit c2b4a8e

Please sign in to comment.