Commit 7a4439c4 authored by M. Mohan Kumar's avatar M. Mohan Kumar Committed by Eric Van Hensbergen

9p: Include fsync support for 9p client

Implement the fsync in the client side by marking stat field values to 'don't touch' so that server may 
interpret it as a request to guarantee that the contents of the associated file are committed to stable 
storage before the Rwstat message is returned.

Without this patch, calling fsync on a 9p file results in "Invalid argument" error. Please check the attached 
C program.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> 
Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> 
Acked-by: default avatarVenkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent 9d6939da
...@@ -60,3 +60,4 @@ void v9fs_dentry_release(struct dentry *); ...@@ -60,3 +60,4 @@ void v9fs_dentry_release(struct dentry *);
int v9fs_uflags2omode(int uflags, int extended); int v9fs_uflags2omode(int uflags, int extended);
ssize_t v9fs_file_readn(struct file *, char *, char __user *, u32, u64); ssize_t v9fs_file_readn(struct file *, char *, char __user *, u32, u64);
void v9fs_blank_wstat(struct p9_wstat *wstat);
...@@ -257,6 +257,23 @@ v9fs_file_write(struct file *filp, const char __user * data, ...@@ -257,6 +257,23 @@ v9fs_file_write(struct file *filp, const char __user * data,
return total; return total;
} }
static int v9fs_file_fsync(struct file *filp, struct dentry *dentry,
int datasync)
{
struct p9_fid *fid;
struct p9_wstat wstat;
int retval;
P9_DPRINTK(P9_DEBUG_VFS, "filp %p dentry %p datasync %x\n", filp,
dentry, datasync);
fid = filp->private_data;
v9fs_blank_wstat(&wstat);
retval = p9_client_wstat(fid, &wstat);
return retval;
}
static const struct file_operations v9fs_cached_file_operations = { static const struct file_operations v9fs_cached_file_operations = {
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
.read = do_sync_read, .read = do_sync_read,
...@@ -266,6 +283,7 @@ static const struct file_operations v9fs_cached_file_operations = { ...@@ -266,6 +283,7 @@ static const struct file_operations v9fs_cached_file_operations = {
.release = v9fs_dir_release, .release = v9fs_dir_release,
.lock = v9fs_file_lock, .lock = v9fs_file_lock,
.mmap = generic_file_readonly_mmap, .mmap = generic_file_readonly_mmap,
.fsync = v9fs_file_fsync,
}; };
const struct file_operations v9fs_file_operations = { const struct file_operations v9fs_file_operations = {
...@@ -276,4 +294,5 @@ const struct file_operations v9fs_file_operations = { ...@@ -276,4 +294,5 @@ const struct file_operations v9fs_file_operations = {
.release = v9fs_dir_release, .release = v9fs_dir_release,
.lock = v9fs_file_lock, .lock = v9fs_file_lock,
.mmap = generic_file_readonly_mmap, .mmap = generic_file_readonly_mmap,
.fsync = v9fs_file_fsync,
}; };
...@@ -176,7 +176,7 @@ int v9fs_uflags2omode(int uflags, int extended) ...@@ -176,7 +176,7 @@ int v9fs_uflags2omode(int uflags, int extended)
* *
*/ */
static void void
v9fs_blank_wstat(struct p9_wstat *wstat) v9fs_blank_wstat(struct p9_wstat *wstat)
{ {
wstat->type = ~0; wstat->type = ~0;
......
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