2 * Copyright (C) 2011+ Evgeniy Polyakov <zbr@ioremap.net>
9 static int pohmelfs_send_prepare_commit(struct pohmelfs_inode
*pi
, size_t len
, loff_t pos
, int prepare
)
11 struct pohmelfs_io io
;
13 memset(&io
, 0, sizeof(struct pohmelfs_io
));
18 io
.cmd
= DNET_CMD_WRITE
;
21 io
.aflags
= DNET_ATTR_NOCSUM
;
23 io
.ioflags
= DNET_IO_FLAGS_PREPARE
;
25 io
.ioflags
= DNET_IO_FLAGS_COMMIT
;
26 io
.ioflags
|= DNET_IO_FLAGS_PLAIN_WRITE
;
28 return pohmelfs_send_io(&io
);
31 static ssize_t
pohmelfs_write(struct file
*filp
, const char __user
*buf
, size_t len
, loff_t
*ppos
)
35 struct inode
*inode
= filp
->f_mapping
->host
;
36 struct pohmelfs_inode
*pi
= pohmelfs_inode(inode
);
37 loff_t offset
= *ppos
;
38 err
= pohmelfs_send_prepare_commit(pi
, len
, offset
, 1);
42 err
= do_sync_write(filp
, buf
, len
, ppos
);
44 pohmelfs_send_prepare_commit(pi
, 0, 0, 0);
50 const struct file_operations pohmelfs_file_ops
= {
51 .open
= generic_file_open
,
53 .llseek
= generic_file_llseek
,
56 .aio_read
= generic_file_aio_read
,
58 .mmap
= generic_file_mmap
,
60 .splice_read
= generic_file_splice_read
,
61 .splice_write
= generic_file_splice_write
,
63 .write
= pohmelfs_write
,
64 .aio_write
= generic_file_aio_write
,
67 const struct inode_operations pohmelfs_file_inode_operations
= {