Whamcloud - gitweb
r=adilger
[fs/lustre-release.git] / lustre / obdfilter / filter_io.c
index 643a427..41659a4 100644 (file)
@@ -506,6 +506,8 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
         struct fsfilt_objinfo fso;
         struct obd_device *obd;
         obd_size left;
+        obd_uid uid;
+        obd_gid gid;
         void *iobuf; 
         
         ENTRY;
@@ -522,6 +524,9 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
         obd = exp->exp_obd;
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
+        uid = oa->o_valid & OBD_MD_FLUID ? oa->o_uid : 0;
+        gid = oa->o_valid & OBD_MD_FLGID ? oa->o_gid : 0;
+        
         /* make sure that object is already allocated */
         dentry = filter_crow_object(obd, oa);
         if (IS_ERR(dentry))
@@ -632,8 +637,14 @@ cleanup:
 int filter_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
                   int objcount, struct obd_ioobj *obj, int niocount,
                   struct niobuf_remote *nb, struct niobuf_local *res,
-                  struct obd_trans_info *oti)
+                  struct obd_trans_info *oti, struct lustre_capa *capa)
 {
+        int rc;
+
+        rc = filter_verify_capa(cmd, exp, capa);
+        if (rc)
+                return rc;
+
         if (cmd == OBD_BRW_WRITE)
                 return filter_preprw_write(cmd, exp, oa, objcount, obj,
                                            niocount, nb, res, oti);
@@ -878,16 +889,29 @@ cleanup:
 
 int filter_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
                     int objcount, struct obd_ioobj *obj, int niocount,
-                    struct niobuf_local *res, struct obd_trans_info *oti,int rc)
+                    struct niobuf_local *res, struct obd_trans_info *oti,int ret)
 {
-        if (cmd == OBD_BRW_WRITE)
-                return filter_commitrw_write(exp, oa, objcount, obj, niocount,
-                                             res, oti, rc);
-        if (cmd == OBD_BRW_READ)
-                return filter_commitrw_read(exp, oa, objcount, obj, niocount,
-                                            res, oti, rc);
-        LBUG();
-        return -EPROTO;
+        int rc = -EPROTO;
+        struct lustre_id *id = obdo_id(oa);
+        __u32 len = sizeof(*id);
+        struct inode * inode = res->dentry->d_inode;
+        struct super_block * sb = res->dentry->d_sb;
+        struct obd_device *obd = class_exp2obd(exp);
+        
+        if (cmd == OBD_BRW_WRITE) {
+                rc = filter_commitrw_write(exp, oa, objcount, obj, niocount,
+                                           res, oti, ret);
+                fsfilt_set_info(obd, sb, inode, 10, "file_write", len, (void*)id);
+        }
+        else if (cmd == OBD_BRW_READ) {
+                rc = filter_commitrw_read(exp, oa, objcount, obj, niocount,
+                                          res, oti, ret);
+                fsfilt_set_info(obd, sb, inode, 9, "file_read", len, (void*)id);
+        }
+        else
+                LBUG();
+
+        return rc;
 }
 
 int filter_brw(int cmd, struct obd_export *exp, struct obdo *oa,
@@ -915,7 +939,7 @@ int filter_brw(int cmd, struct obd_export *exp, struct obdo *oa,
         obdo_to_ioobj(oa, &ioo);
         ioo.ioo_bufcnt = oa_bufs;
 
-        ret = filter_preprw(cmd, exp, oa, 1, &ioo, oa_bufs, rnb, lnb, oti);
+        ret = filter_preprw(cmd, exp, oa, 1, &ioo, oa_bufs, rnb, lnb, oti,NULL);
         if (ret != 0)
                 GOTO(out, ret);