Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 210392
b: refs/heads/master
c: dd43bcd
h: refs/heads/master
v: v3
  • Loading branch information
Mark Fasheh authored and Tao Ma committed Sep 8, 2010
1 parent f8fdd62 commit 36b960c
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 33 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: e49e27674d1dd2717ad90b21ece8f83102153315
refs/heads/master: dd43bcde23c527f64897eef41aa1fed2c9905ea9
120 changes: 88 additions & 32 deletions trunk/fs/ocfs2/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1871,61 +1871,117 @@ static int ocfs2_blkno_stringify(u64 blkno, char *name)
return status;
}

static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
struct inode **ret_orphan_dir,
u64 blkno,
char *name,
struct ocfs2_dir_lookup_result *lookup)
static int ocfs2_lookup_lock_orphan_dir(struct ocfs2_super *osb,
struct inode **ret_orphan_dir,
struct buffer_head **ret_orphan_dir_bh)
{
struct inode *orphan_dir_inode;
struct buffer_head *orphan_dir_bh = NULL;
int status = 0;

status = ocfs2_blkno_stringify(blkno, name);
if (status < 0) {
mlog_errno(status);
return status;
}
int ret = 0;

orphan_dir_inode = ocfs2_get_system_file_inode(osb,
ORPHAN_DIR_SYSTEM_INODE,
osb->slot_num);
if (!orphan_dir_inode) {
status = -ENOENT;
mlog_errno(status);
return status;
ret = -ENOENT;
mlog_errno(ret);
return ret;
}

mutex_lock(&orphan_dir_inode->i_mutex);

status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
if (status < 0) {
mlog_errno(status);
goto leave;
ret = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
if (ret < 0) {
mutex_unlock(&orphan_dir_inode->i_mutex);
iput(orphan_dir_inode);

mlog_errno(ret);
return ret;
}

status = ocfs2_prepare_dir_for_insert(osb, orphan_dir_inode,
orphan_dir_bh, name,
OCFS2_ORPHAN_NAMELEN, lookup);
if (status < 0) {
ocfs2_inode_unlock(orphan_dir_inode, 1);
*ret_orphan_dir = orphan_dir_inode;
*ret_orphan_dir_bh = orphan_dir_bh;

mlog_errno(status);
goto leave;
return 0;
}

static int __ocfs2_prepare_orphan_dir(struct inode *orphan_dir_inode,
struct buffer_head *orphan_dir_bh,
u64 blkno,
char *name,
struct ocfs2_dir_lookup_result *lookup)
{
int ret;
struct ocfs2_super *osb = OCFS2_SB(orphan_dir_inode->i_sb);

ret = ocfs2_blkno_stringify(blkno, name);
if (ret < 0) {
mlog_errno(ret);
return ret;
}

ret = ocfs2_prepare_dir_for_insert(osb, orphan_dir_inode,
orphan_dir_bh, name,
OCFS2_ORPHAN_NAMELEN, lookup);
if (ret < 0) {
mlog_errno(ret);
return ret;
}

return 0;
}

/**
* ocfs2_prepare_orphan_dir() - Prepare an orphan directory for
* insertion of an orphan.
* @osb: ocfs2 file system
* @ret_orphan_dir: Orphan dir inode - returned locked!
* @blkno: Actual block number of the inode to be inserted into orphan dir.
* @lookup: dir lookup result, to be passed back into functions like
* ocfs2_orphan_add
*
* Returns zero on success and the ret_orphan_dir, name and lookup
* fields will be populated.
*
* Returns non-zero on failure.
*/
static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
struct inode **ret_orphan_dir,
u64 blkno,
char *name,
struct ocfs2_dir_lookup_result *lookup)
{
struct inode *orphan_dir_inode = NULL;
struct buffer_head *orphan_dir_bh = NULL;
int ret = 0;

ret = ocfs2_lookup_lock_orphan_dir(osb, &orphan_dir_inode,
&orphan_dir_bh);
if (ret < 0) {
mlog_errno(ret);
return ret;
}

ret = __ocfs2_prepare_orphan_dir(orphan_dir_inode, orphan_dir_bh,
blkno, name, lookup);
if (ret < 0) {
mlog_errno(ret);
goto out;
}

*ret_orphan_dir = orphan_dir_inode;

leave:
if (status) {
out:
brelse(orphan_dir_bh);

if (ret) {
ocfs2_inode_unlock(orphan_dir_inode, 1);
mutex_unlock(&orphan_dir_inode->i_mutex);
iput(orphan_dir_inode);
}

brelse(orphan_dir_bh);

mlog_exit(status);
return status;
mlog_exit(ret);
return ret;
}

static int ocfs2_orphan_add(struct ocfs2_super *osb,
Expand Down

0 comments on commit 36b960c

Please sign in to comment.