From 37fae20098ae960615a195973ee6e136fcd2308a Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 4 Mar 2011 12:47:29 +1100 Subject: [PATCH] roll: change handling of distinction between rename to existing and non-existing name Having DIROP_REN_TARGET_OLD and DIROP_REN_TARGET_NEW is not needed as the miniblock also holds the inode number from the target which can be zero or non-zero. So remove that distinction and just use the inode number. Signed-off-by: NeilBrown --- dir.c | 7 +++---- layout.h | 3 +-- roll.c | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/dir.c b/dir.c index 713ccb2..ae1d083 100644 --- a/dir.c +++ b/dir.c @@ -605,8 +605,7 @@ static void dir_log_commit(struct update_handle *uh, han = hancnt; *handle = han; break; - case DIROP_REN_NEW_TARGET: - case DIROP_REN_OLD_TARGET: + case DIROP_REN_TARGET: han = *handle; break; default: @@ -1235,8 +1234,8 @@ retry: dir_log_commit(&old_uh, fs, old_dir, &old_dentry->d_name, old_inode->i_ino, DIROP_REN_SOURCE, &renhandle); dir_log_commit(&new_uh, fs, new_dir, &new_dentry->d_name, - 0, - new_inode ? DIROP_REN_OLD_TARGET : DIROP_REN_NEW_TARGET, + new_inode ? new_inode->i_ino : 0, + DIROP_REN_TARGET, &renhandle); if (S_ISDIR(old_inode->i_mode)) { inode_dec_link_count(old_dir); diff --git a/layout.h b/layout.h index 5c6ba0e..fed1473 100644 --- a/layout.h +++ b/layout.h @@ -252,8 +252,7 @@ struct dirheader { #define DIROP_LINK 0 #define DIROP_UNLINK 1 #define DIROP_REN_SOURCE 2 -#define DIROP_REN_NEW_TARGET 3 -#define DIROP_REN_OLD_TARGET 4 +#define DIROP_REN_TARGET 3 /* * The orphan file has a very simple structure with diff --git a/roll.c b/roll.c index e558552..d420798 100644 --- a/roll.c +++ b/roll.c @@ -249,12 +249,24 @@ roll_mini(struct fs *fs, int fsnum, int inum, int trunc, * different objects. * * inode-files: meta-data updates, including size, are allowed. - * index update and data update are not (data update must + * index update and data update are not (data update must * go through the file). Implied creation requires * orphan handling - * regular-files: just over-write data, possibly extending size + * regular-files: could just over-write data, possibly extending size + * but there doesn't seem to be any reason to create such updates + * so we don't bother to try handling them. * symlink,dev,pipe: as with reg-files - * directory: add/remove entries. + * directory: add/remove entries. Each miniblock has an address and + * identifies a name, an inode number, and one of: + * LINK - create a link with this name to the inode + * UNLINK - remove the link + * REN_SOURCE - record this info against the 'address' which must + * be unique in this checkpoint across all directories + * REN_TARGET - The source with matching 'address' is being + * renamed to here. So unlink the source and either create the + * target (if inode is zero) or replace the target. This + * miniblock could be in a different directory to the matching + * REN_SOURCE. */ inode = lafs_iget_fs(fs, fsnum, inum, SYNC); -- 2.39.5