ceph: factor out libceph from Ceph file system
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / ceph / ioctl.c
index d085f07756b42159c7c3b916b123bdeabbfc35b8..899578b0c46b0c1aaa7818bd994451601bda6866 100644 (file)
@@ -1,8 +1,10 @@
 #include <linux/in.h>
 
-#include "ioctl.h"
 #include "super.h"
-#include "ceph_debug.h"
+#include "mds_client.h"
+#include <linux/ceph/ceph_debug.h>
+
+#include "ioctl.h"
 
 
 /*
@@ -37,7 +39,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
 {
        struct inode *inode = file->f_dentry->d_inode;
        struct inode *parent_inode = file->f_dentry->d_parent->d_inode;
-       struct ceph_mds_client *mdsc = &ceph_sb_to_client(inode->i_sb)->mdsc;
+       struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
        struct ceph_mds_request *req;
        struct ceph_ioctl_layout l;
        int err, i;
@@ -98,7 +100,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
        struct ceph_ioctl_dataloc dl;
        struct inode *inode = file->f_dentry->d_inode;
        struct ceph_inode_info *ci = ceph_inode(inode);
-       struct ceph_osd_client *osdc = &ceph_sb_to_client(inode->i_sb)->osdc;
+       struct ceph_osd_client *osdc =
+               &ceph_sb_to_client(inode->i_sb)->client->osdc;
        u64 len = 1, olen;
        u64 tmp;
        struct ceph_object_layout ol;
@@ -143,6 +146,27 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
        return 0;
 }
 
+static long ceph_ioctl_lazyio(struct file *file)
+{
+       struct ceph_file_info *fi = file->private_data;
+       struct inode *inode = file->f_dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+
+       if ((fi->fmode & CEPH_FILE_MODE_LAZY) == 0) {
+               spin_lock(&inode->i_lock);
+               ci->i_nr_by_mode[fi->fmode]--;
+               fi->fmode |= CEPH_FILE_MODE_LAZY;
+               ci->i_nr_by_mode[fi->fmode]++;
+               spin_unlock(&inode->i_lock);
+               dout("ioctl_layzio: file %p marked lazy\n", file);
+
+               ceph_check_caps(ci, 0, NULL);
+       } else {
+               dout("ioctl_layzio: file %p already lazy\n", file);
+       }
+       return 0;
+}
+
 long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        dout("ioctl file %p cmd %u arg %lu\n", file, cmd, arg);
@@ -155,6 +179,9 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
        case CEPH_IOC_GET_DATALOC:
                return ceph_ioctl_get_dataloc(file, (void __user *)arg);
+
+       case CEPH_IOC_LAZYIO:
+               return ceph_ioctl_lazyio(file);
        }
        return -ENOTTY;
 }