Skip to content

Commit aacc954

Browse files
Russell KingAl Viro
authored andcommitted
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: Russell King <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent cc625cc commit aacc954

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

fs/adfs/adfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ struct adfs_dir_ops {
130130
int (*update)(struct adfs_dir *dir, struct object_info *obj);
131131
int (*create)(struct adfs_dir *dir, struct object_info *obj);
132132
int (*remove)(struct adfs_dir *dir, struct object_info *obj);
133+
int (*commit)(struct adfs_dir *dir);
133134
};
134135

135136
struct adfs_discmap {

fs/adfs/dir.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ adfs_dir_update(struct super_block *sb, struct object_info *obj, int wait)
293293
goto unlock;
294294

295295
ret = ops->update(&dir, obj);
296+
if (ret)
297+
goto forget;
298+
299+
ret = ops->commit(&dir);
296300
if (ret)
297301
goto forget;
298302
up_write(&adfs_dir_rwsem);

fs/adfs/dir_f.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -292,25 +292,24 @@ static int adfs_f_update(struct adfs_dir *dir, struct object_info *obj)
292292
adfs_obj2dir(&de, obj);
293293

294294
/* Write the directory entry back to the directory */
295-
ret = adfs_dir_copyto(dir, pos, &de, 26);
296-
if (ret)
297-
return ret;
298-
299-
/*
300-
* Increment directory sequence number
301-
*/
295+
return adfs_dir_copyto(dir, offset, &de, 26);
296+
}
297+
298+
static int adfs_f_commit(struct adfs_dir *dir)
299+
{
300+
int ret;
301+
302+
/* Increment directory sequence number */
302303
dir->dirhead->startmasseq += 1;
303304
dir->newtail->endmasseq += 1;
304305

305-
ret = adfs_dir_checkbyte(dir);
306-
/*
307-
* Update directory check byte
308-
*/
309-
dir->newtail->dircheckbyte = ret;
306+
/* Update directory check byte */
307+
dir->newtail->dircheckbyte = adfs_dir_checkbyte(dir);
310308

309+
/* Make sure the directory still validates correctly */
311310
ret = adfs_f_validate(dir);
312311
if (ret)
313-
adfs_error(dir->sb, "whoops! I broke a directory!");
312+
adfs_msg(dir->sb, KERN_ERR, "error: update broke directory");
314313

315314
return ret;
316315
}
@@ -321,4 +320,5 @@ const struct adfs_dir_ops adfs_f_dir_ops = {
321320
.setpos = adfs_f_setpos,
322321
.getnext = adfs_f_getnext,
323322
.update = adfs_f_update,
323+
.commit = adfs_f_commit,
324324
};

0 commit comments

Comments
 (0)