Whamcloud - gitweb
Added scripts to parse output per Peter Braam
[fs/lustre-release.git] / lustre / obdfilter / filter_io.c
index 1c9cd4d..75c4b51 100644 (file)
@@ -264,7 +264,8 @@ static int filter_preprw_read(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)
 {
         struct obd_device *obd = exp->exp_obd;
         struct lvfs_run_ctxt saved;
@@ -303,6 +304,12 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
 
         inode = dentry->d_inode; 
 
+        if (inode) {
+                rc = filter_verify_fid(exp, inode, capa);
+                if (rc)
+                        GOTO(cleanup, rc);
+        }
+
         fsfilt_check_slow(now, obd_timeout, "preprw_read setup");
 
         for (i = 0, lnb = res, rnb = nb; i < obj->ioo_bufcnt;
@@ -399,7 +406,7 @@ static int filter_grant_check(struct obd_export *exp, int objcount,
                 for (i = 0; i < fso[obj].fso_bufcnt; i++, n++) {
                         int tmp, bytes;
 
-                        /* FIXME: this is calculated with PAGE_SIZE on client */
+                        /* XXX: this is calculated with PAGE_SIZE on client */
                         bytes = rnb[n].len;
                         bytes += rnb[n].offset & (blocksize - 1);
                         tmp = (rnb[n].offset + rnb[n].len) & (blocksize - 1);
@@ -477,7 +484,6 @@ static int filter_grant_check(struct obd_export *exp, int objcount,
         }
         exp->exp_obd->u.filter.fo_tot_dirty -= used;
         fed->fed_dirty -= used;
-
         return rc;
 }
 
@@ -495,16 +501,17 @@ static int filter_preprw_write(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 = 0, i, tot_bytes = 0, cleanup_phase = 0;
+        struct obd_device *obd = exp->exp_obd;
         struct niobuf_local *lnb = res;
         struct dentry *dentry = NULL;
         unsigned long now = jiffies;
         struct lvfs_run_ctxt saved;
         struct niobuf_remote *rnb;
         struct fsfilt_objinfo fso;
-        struct obd_device *obd;
         obd_size left;
         void *iobuf; 
         
@@ -523,26 +530,16 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
         /* make sure that object is already allocated */
-        dentry = filter_crow_object(obd, obj->ioo_gr,
-                                    obj->ioo_id);
-
+        dentry = filter_crow_object(obd, oa);
         if (IS_ERR(dentry))
                 GOTO(cleanup, rc = PTR_ERR(dentry));
 
+        rc = filter_verify_fid(exp, dentry->d_inode, capa);
+        if (rc)
+                GOTO(cleanup, rc);
+
         cleanup_phase = 2;
 
-        /* 
-         * setting attrs passed along with write requests (owner/group). We
-         * goind it here as object should not exist with wrong owner/group as
-         * this may break quotas. --umka
-         */
-        rc = filter_setattr_internal(exp, dentry, oa, NULL);
-        if (rc) {
-                CERROR("cannot set attrs on write, err %d\n",
-                       rc);
-                GOTO(cleanup, rc);
-        }
-        
         fso.fso_dentry = dentry;
         fso.fso_bufcnt = obj->ioo_bufcnt;
 
@@ -646,15 +643,21 @@ 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);
+                                           niocount, nb, res, oti, capa);
 
         if (cmd == OBD_BRW_READ)
                 return filter_preprw_read(cmd, exp, oa, objcount, obj,
-                                          niocount, nb, res, oti);
+                                          niocount, nb, res, oti, capa);
 
         LBUG();
         return -EPROTO;
@@ -793,9 +796,9 @@ int filter_do_cow(struct obd_export *exp, struct obd_ioobj *obj,
         }
         
         flags = fsfilt_get_fs_flags(exp->exp_obd, dentry);
-        if (!(flags & SM_DO_COW)) {
+        if (!(flags & SM_DO_COW))
                 GOTO(cleanup, rc);
-        }
+
         OBD_ALLOC(extents, obj->ioo_bufcnt * sizeof(struct write_extents)); 
         if (!extents) {
                 CERROR("No Memory\n");
@@ -824,6 +827,7 @@ cleanup:
         RETURN(rc);
 
 }
+
 int filter_write_extents(struct obd_export *exp, struct obd_ioobj *obj, int nobj,
                          int niocount, struct niobuf_local *local, int rc)
 {
@@ -853,9 +857,8 @@ int filter_write_extents(struct obd_export *exp, struct obd_ioobj *obj, int nobj
         }
         
         flags = fsfilt_get_fs_flags(exp->exp_obd, dentry);
-        if (!(flags & SM_DO_REC)) {
+        if (!(flags & SM_DO_REC))
                 GOTO(cleanup, rc);
-        }
 
         for (i = 0, lnb = local; i < obj->ioo_bufcnt; i++, lnb++) {
                 if (len == 0) {
@@ -892,16 +895,32 @@ 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;
+        /* remove that audit handlers due to fsfilt_inode_map_pages hooks
+        //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);
+        */
+        current->user->nid = oti->oti_nid;
+        
+        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,
@@ -929,7 +948,8 @@ 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);