Commit aacc954c authored by Russell King's avatar Russell King Committed by Al Viro

fs/adfs: newdir: split out directory commit from update

After changing a directory, we need to update the sequence numbers and
calculate the new check byte before the directory is scheduled to be
written back to the media.  Since this needs to happen for any change
to the directory, move this into a separate method.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent cc625ccd
...@@ -130,6 +130,7 @@ struct adfs_dir_ops { ...@@ -130,6 +130,7 @@ struct adfs_dir_ops {
int (*update)(struct adfs_dir *dir, struct object_info *obj); int (*update)(struct adfs_dir *dir, struct object_info *obj);
int (*create)(struct adfs_dir *dir, struct object_info *obj); int (*create)(struct adfs_dir *dir, struct object_info *obj);
int (*remove)(struct adfs_dir *dir, struct object_info *obj); int (*remove)(struct adfs_dir *dir, struct object_info *obj);
int (*commit)(struct adfs_dir *dir);
}; };
struct adfs_discmap { struct adfs_discmap {
......
...@@ -293,6 +293,10 @@ adfs_dir_update(struct super_block *sb, struct object_info *obj, int wait) ...@@ -293,6 +293,10 @@ adfs_dir_update(struct super_block *sb, struct object_info *obj, int wait)
goto unlock; goto unlock;
ret = ops->update(&dir, obj); ret = ops->update(&dir, obj);
if (ret)
goto forget;
ret = ops->commit(&dir);
if (ret) if (ret)
goto forget; goto forget;
up_write(&adfs_dir_rwsem); up_write(&adfs_dir_rwsem);
......
...@@ -292,25 +292,24 @@ static int adfs_f_update(struct adfs_dir *dir, struct object_info *obj) ...@@ -292,25 +292,24 @@ static int adfs_f_update(struct adfs_dir *dir, struct object_info *obj)
adfs_obj2dir(&de, obj); adfs_obj2dir(&de, obj);
/* Write the directory entry back to the directory */ /* Write the directory entry back to the directory */
ret = adfs_dir_copyto(dir, pos, &de, 26); return adfs_dir_copyto(dir, offset, &de, 26);
if (ret) }
return ret;
/* static int adfs_f_commit(struct adfs_dir *dir)
* Increment directory sequence number {
*/ int ret;
/* Increment directory sequence number */
dir->dirhead->startmasseq += 1; dir->dirhead->startmasseq += 1;
dir->newtail->endmasseq += 1; dir->newtail->endmasseq += 1;
ret = adfs_dir_checkbyte(dir); /* Update directory check byte */
/* dir->newtail->dircheckbyte = adfs_dir_checkbyte(dir);
* Update directory check byte
*/
dir->newtail->dircheckbyte = ret;
/* Make sure the directory still validates correctly */
ret = adfs_f_validate(dir); ret = adfs_f_validate(dir);
if (ret) if (ret)
adfs_error(dir->sb, "whoops! I broke a directory!"); adfs_msg(dir->sb, KERN_ERR, "error: update broke directory");
return ret; return ret;
} }
...@@ -321,4 +320,5 @@ const struct adfs_dir_ops adfs_f_dir_ops = { ...@@ -321,4 +320,5 @@ const struct adfs_dir_ops adfs_f_dir_ops = {
.setpos = adfs_f_setpos, .setpos = adfs_f_setpos,
.getnext = adfs_f_getnext, .getnext = adfs_f_getnext,
.update = adfs_f_update, .update = adfs_f_update,
.commit = adfs_f_commit,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment