Skip to content

Commit acf5f0b

Browse files
Russell KingAl Viro
authored andcommitted
fs/adfs: dir: add common directory sync method
adfs_fplus_sync() can be used for both directory formats since we now have a common way to access the buffer heads, so move it into dir.c and appropriately rename it. Remove the directory-format specific implementations. Signed-off-by: Russell King <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 1dd9f5b commit acf5f0b

File tree

4 files changed

+18
-40
lines changed

4 files changed

+18
-40
lines changed

fs/adfs/adfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ struct adfs_dir_ops {
125125
int (*update)(struct adfs_dir *dir, struct object_info *obj);
126126
int (*create)(struct adfs_dir *dir, struct object_info *obj);
127127
int (*remove)(struct adfs_dir *dir, struct object_info *obj);
128-
int (*sync)(struct adfs_dir *dir);
129128
};
130129

131130
struct adfs_discmap {

fs/adfs/dir.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ static int adfs_dir_read(struct super_block *sb, u32 indaddr,
3838
return ADFS_SB(sb)->s_dir->read(sb, indaddr, size, dir);
3939
}
4040

41+
static int adfs_dir_sync(struct adfs_dir *dir)
42+
{
43+
int err = 0;
44+
int i;
45+
46+
for (i = dir->nr_buffers - 1; i >= 0; i--) {
47+
struct buffer_head *bh = dir->bhs[i];
48+
sync_dirty_buffer(bh);
49+
if (buffer_req(bh) && !buffer_uptodate(bh))
50+
err = -EIO;
51+
}
52+
53+
return err;
54+
}
55+
4156
void adfs_object_fixup(struct adfs_dir *dir, struct object_info *obj)
4257
{
4358
unsigned int dots, i;
@@ -135,10 +150,8 @@ adfs_dir_update(struct super_block *sb, struct object_info *obj, int wait)
135150
printk(KERN_INFO "adfs_dir_update: object %06x in dir %06x\n",
136151
obj->indaddr, obj->parent_id);
137152

138-
if (!ops->update) {
139-
ret = -EINVAL;
140-
goto out;
141-
}
153+
if (!ops->update)
154+
return -EINVAL;
142155

143156
ret = adfs_dir_read(sb, obj->parent_id, 0, &dir);
144157
if (ret)
@@ -149,7 +162,7 @@ adfs_dir_update(struct super_block *sb, struct object_info *obj, int wait)
149162
write_unlock(&adfs_dir_lock);
150163

151164
if (wait) {
152-
int err = ops->sync(&dir);
165+
int err = adfs_dir_sync(&dir);
153166
if (!ret)
154167
ret = err;
155168
}

fs/adfs/dir_f.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -414,26 +414,9 @@ adfs_f_update(struct adfs_dir *dir, struct object_info *obj)
414414
#endif
415415
}
416416

417-
static int
418-
adfs_f_sync(struct adfs_dir *dir)
419-
{
420-
int err = 0;
421-
int i;
422-
423-
for (i = dir->nr_buffers - 1; i >= 0; i--) {
424-
struct buffer_head *bh = dir->bh[i];
425-
sync_dirty_buffer(bh);
426-
if (buffer_req(bh) && !buffer_uptodate(bh))
427-
err = -EIO;
428-
}
429-
430-
return err;
431-
}
432-
433417
const struct adfs_dir_ops adfs_f_dir_ops = {
434418
.read = adfs_f_read,
435419
.setpos = adfs_f_setpos,
436420
.getnext = adfs_f_getnext,
437421
.update = adfs_f_update,
438-
.sync = adfs_f_sync,
439422
};

fs/adfs/dir_fplus.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -179,25 +179,8 @@ adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj)
179179
return ret;
180180
}
181181

182-
static int
183-
adfs_fplus_sync(struct adfs_dir *dir)
184-
{
185-
int err = 0;
186-
int i;
187-
188-
for (i = dir->nr_buffers - 1; i >= 0; i--) {
189-
struct buffer_head *bh = dir->bhs[i];
190-
sync_dirty_buffer(bh);
191-
if (buffer_req(bh) && !buffer_uptodate(bh))
192-
err = -EIO;
193-
}
194-
195-
return err;
196-
}
197-
198182
const struct adfs_dir_ops adfs_fplus_dir_ops = {
199183
.read = adfs_fplus_read,
200184
.setpos = adfs_fplus_setpos,
201185
.getnext = adfs_fplus_getnext,
202-
.sync = adfs_fplus_sync,
203186
};

0 commit comments

Comments
 (0)