Skip to content

Commit 05459ca

Browse files
author
Al Viro
committed
repair sysv_write_inode(), switch sysv to simple_fsync()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 0d7916d commit 05459ca

4 files changed

Lines changed: 18 additions & 47 deletions

File tree

‎fs/sysv/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static int sysv_readdir(struct file *, void *, filldir_t);
2424
const struct file_operations sysv_dir_operations = {
2525
.read = generic_read_dir,
2626
.readdir = sysv_readdir,
27-
.fsync = sysv_sync_file,
27+
.fsync = simple_fsync,
2828
};
2929

3030
static inline void dir_put_page(struct page *page)

‎fs/sysv/file.c‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,11 @@ const struct file_operations sysv_file_operations = {
2626
.write = do_sync_write,
2727
.aio_write = generic_file_aio_write,
2828
.mmap = generic_file_mmap,
29-
.fsync = sysv_sync_file,
29+
.fsync = simple_fsync,
3030
.splice_read = generic_file_splice_read,
3131
};
3232

3333
const struct inode_operations sysv_file_inode_operations = {
3434
.truncate = sysv_truncate,
3535
.getattr = sysv_getattr,
3636
};
37-
38-
int sysv_sync_file(struct file * file, struct dentry *dentry, int datasync)
39-
{
40-
struct inode *inode = dentry->d_inode;
41-
int err;
42-
43-
err = sync_mapping_buffers(inode->i_mapping);
44-
if (!(inode->i_state & I_DIRTY))
45-
return err;
46-
if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
47-
return err;
48-
49-
err |= sysv_sync_inode(inode);
50-
return err ? -EIO : 0;
51-
}

‎fs/sysv/inode.c‎

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -247,27 +247,29 @@ struct inode *sysv_iget(struct super_block *sb, unsigned int ino)
247247
return ERR_PTR(-EIO);
248248
}
249249

250-
static struct buffer_head * sysv_update_inode(struct inode * inode)
250+
int sysv_write_inode(struct inode *inode, int wait)
251251
{
252252
struct super_block * sb = inode->i_sb;
253253
struct sysv_sb_info * sbi = SYSV_SB(sb);
254254
struct buffer_head * bh;
255255
struct sysv_inode * raw_inode;
256256
struct sysv_inode_info * si;
257257
unsigned int ino, block;
258+
int err = 0;
258259

259260
ino = inode->i_ino;
260261
if (!ino || ino > sbi->s_ninodes) {
261262
printk("Bad inode number on dev %s: %d is out of range\n",
262263
inode->i_sb->s_id, ino);
263-
return NULL;
264+
return -EIO;
264265
}
265266
raw_inode = sysv_raw_inode(sb, ino, &bh);
266267
if (!raw_inode) {
267268
printk("unable to read i-node block\n");
268-
return NULL;
269+
return -EIO;
269270
}
270271

272+
lock_kernel();
271273
raw_inode->i_mode = cpu_to_fs16(sbi, inode->i_mode);
272274
raw_inode->i_uid = cpu_to_fs16(sbi, fs_high2lowuid(inode->i_uid));
273275
raw_inode->i_gid = cpu_to_fs16(sbi, fs_high2lowgid(inode->i_gid));
@@ -283,38 +285,23 @@ static struct buffer_head * sysv_update_inode(struct inode * inode)
283285
for (block = 0; block < 10+1+1+1; block++)
284286
write3byte(sbi, (u8 *)&si->i_data[block],
285287
&raw_inode->i_data[3*block]);
288+
unlock_kernel();
286289
mark_buffer_dirty(bh);
287-
return bh;
288-
}
289-
290-
int sysv_write_inode(struct inode * inode, int wait)
291-
{
292-
struct buffer_head *bh;
293-
lock_kernel();
294-
bh = sysv_update_inode(inode);
290+
if (wait) {
291+
sync_dirty_buffer(bh);
292+
if (buffer_req(bh) && !buffer_uptodate(bh)) {
293+
printk ("IO error syncing sysv inode [%s:%08x]\n",
294+
sb->s_id, ino);
295+
err = -EIO;
296+
}
297+
}
295298
brelse(bh);
296-
unlock_kernel();
297299
return 0;
298300
}
299301

300-
int sysv_sync_inode(struct inode * inode)
302+
int sysv_sync_inode(struct inode *inode)
301303
{
302-
int err = 0;
303-
struct buffer_head *bh;
304-
305-
bh = sysv_update_inode(inode);
306-
if (bh && buffer_dirty(bh)) {
307-
sync_dirty_buffer(bh);
308-
if (buffer_req(bh) && !buffer_uptodate(bh)) {
309-
printk ("IO error syncing sysv inode [%s:%08lx]\n",
310-
inode->i_sb->s_id, inode->i_ino);
311-
err = -1;
312-
}
313-
}
314-
else if (!bh)
315-
err = -1;
316-
brelse (bh);
317-
return err;
304+
return sysv_write_inode(inode, 1);
318305
}
319306

320307
static void sysv_delete_inode(struct inode *inode)

‎fs/sysv/sysv.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ extern int __sysv_write_begin(struct file *file, struct address_space *mapping,
144144
extern struct inode *sysv_iget(struct super_block *, unsigned int);
145145
extern int sysv_write_inode(struct inode *, int);
146146
extern int sysv_sync_inode(struct inode *);
147-
extern int sysv_sync_file(struct file *, struct dentry *, int);
148147
extern void sysv_set_inode(struct inode *, dev_t);
149148
extern int sysv_getattr(struct vfsmount *, struct dentry *, struct kstat *);
150149
extern int sysv_init_icache(void);

0 commit comments

Comments
 (0)