Whamcloud - gitweb
fixes:
authorlsy <lsy>
Mon, 22 Aug 2005 08:31:00 +0000 (08:31 +0000)
committerlsy <lsy>
Mon, 22 Aug 2005 08:31:00 +0000 (08:31 +0000)
* pack fid for direct io.
* seperate verify_fid from verify_capa to fully support truncate.
* debug message cleanup.

lustre/llite/llite_capa.c
lustre/llite/rw.c
lustre/mdc/mdc_request.c
lustre/obdclass/capa.c
lustre/obdfilter/filter.c
lustre/obdfilter/filter_capa.c
lustre/obdfilter/filter_internal.h
lustre/obdfilter/filter_io.c
lustre/utils/wiretest.c

index 717f6bd..ee3585f 100644 (file)
@@ -232,8 +232,6 @@ int ll_set_och_capa(struct inode *inode, struct lookup_intent *it,
         if (!och->och_capa)
                 rc = -ENOMEM;
 
-        DEBUG_CAPA(D_INFO, capa, "ll_set_och_capa");
-
         expiry = expiry_to_jiffies(capa->lc_expiry - capa_pre_expiry(capa));
 
         spin_lock(&capa_lock);
index 3b142fa..c1cdda9 100644 (file)
@@ -230,6 +230,7 @@ int ll_prepare_write(struct file *file, struct page *page,
 
         oa->o_fsuid = current->fsuid;
         oa->o_valid |= OBD_MD_FLFSUID;
+        *(obdo_id(oa)) = ll_i2info(inode)->lli_id;
 
         rc = obd_brw(OBD_BRW_CHECK, ll_i2dtexp(inode),
                      oa, lsm, 1, &pga, NULL);
index 0783b35..55a447b 100644 (file)
@@ -138,8 +138,6 @@ mdc_interpret_getattr(struct ptlrpc_request *req, void *unused, int rc)
         if (rc)
                 RETURN(rc);
 
-        DEBUG_CAPA(D_INFO, capa, "capa renewal");
-
         spin_lock(&capa_lock);
         expiry = expiry_to_jiffies(capa->lc_expiry - capa_pre_expiry(capa));
         if (time_before(expiry, ll_capa_timer.expires) ||
index c3bbaee..08dccb6 100644 (file)
@@ -91,9 +91,6 @@ find_capa(struct hlist_head *head, uid_t uid, int capa_op, __u64 mdsid,
         struct obd_capa *ocapa;
         uid_t ouid;
 
-        CDEBUG(D_CACHE, "find_capa uid %u op %u mdsid "LPU64" ino %lu "
-               "type %d\n", uid, capa_op, mdsid, ino, type);
-
         hlist_for_each_entry(ocapa, pos, head, c_hash) {
                 if (ocapa->c_capa.lc_ino != ino)
                         continue;
@@ -113,6 +110,8 @@ find_capa(struct hlist_head *head, uid_t uid, int capa_op, __u64 mdsid,
                 if (ouid != uid)
                         continue;
 
+                DEBUG_CAPA(D_CACHE, &ocapa->c_capa, "found");
+
                 return ocapa;
         }
 
@@ -129,7 +128,6 @@ find_capa_locked(struct hlist_head *head, uid_t uid, int capa_op, __u64 mdsid,
                  unsigned long ino, int type)
 {
         struct obd_capa *ocapa;
-        ENTRY;
 
         spin_lock(&capa_lock);
         ocapa = find_capa(head, uid, capa_op, mdsid, ino, type);
@@ -137,7 +135,7 @@ find_capa_locked(struct hlist_head *head, uid_t uid, int capa_op, __u64 mdsid,
                 __capa_get(ocapa);
         spin_unlock(&capa_lock);
 
-        RETURN(ocapa);
+        return ocapa;
 }
 
 static struct obd_capa *alloc_capa(void)
@@ -225,11 +223,10 @@ get_new_capa_locked(struct hlist_head *head, int type, struct lustre_capa *capa,
         __u64 mdsid = capa->lc_mdsid;
         unsigned long ino = capa->lc_ino;
         struct obd_capa *ocapa, *old;
-        ENTRY;
 
         ocapa = alloc_capa();
         if (!ocapa)
-                RETURN(NULL);
+                return NULL;
 
         spin_lock(&capa_lock);
         old = find_capa(head, uid, capa_op, mdsid, ino, type);
@@ -247,6 +244,8 @@ get_new_capa_locked(struct hlist_head *head, int type, struct lustre_capa *capa,
                         memcpy(&ocapa->c_handle, handle, sizeof(*handle));
                 }
 
+                DEBUG_CAPA(D_CACHE, &ocapa->c_capa, "new");
+
                 list_add_capa(ocapa, &capa_list[type]);
                 hlist_add_head(&ocapa->c_hash, capa_hash);
                 capa_count[type]++;
@@ -273,14 +272,14 @@ get_new_capa_locked(struct hlist_head *head, int type, struct lustre_capa *capa,
                 }
                                         
                 spin_unlock(&capa_lock);
-                RETURN(ocapa);
+                return ocapa;
         }
 
         __capa_get(old);
         spin_unlock(&capa_lock);
 
         destroy_capa(ocapa);
-        RETURN(old);
+        return old;
 }
 
 static struct obd_capa *
@@ -291,15 +290,14 @@ capa_get_locked(uid_t uid, int capa_op,__u64 mdsid, unsigned long ino,
         struct hlist_head *head = capa_hash +
                                   capa_hashfn(uid, capa_op, mdsid, ino);
         struct obd_capa *ocapa;
-        ENTRY;
 
         ocapa = find_capa_locked(head, uid, capa_op, mdsid, ino, type);
         if (ocapa)
-                RETURN(ocapa);
+                return ocapa;
         
         if (capa)
                 ocapa = get_new_capa_locked(head, type, capa, inode, handle);
-        RETURN(ocapa);
+        return ocapa;
 }
 
 struct obd_capa *
@@ -365,6 +363,8 @@ static int update_capa_locked(struct lustre_capa *capa, int type)
 
 int capa_renew(struct lustre_capa *capa, int type)
 {
+        DEBUG_CAPA(D_INFO, capa, "renew");
+
         return update_capa_locked(capa, type);
 }
 
index 7134fb3..b132dde 100644 (file)
@@ -2191,9 +2191,10 @@ int filter_setattr(struct obd_export *exp, struct obdo *oa,
         if (IS_ERR(dentry))
                 GOTO(out_pop, rc = PTR_ERR(dentry));
 
-        rc = filter_verify_capa(OBD_BRW_WRITE, exp, dentry->d_inode, capa);
+        rc = filter_verify_fid(exp, dentry->d_inode, capa);
         if (rc)
-                RETURN(rc);
+                GOTO(out_pop, rc);
+
         lock_kernel();
 
         /* setting objects attributes (including owner/group) */
@@ -2736,12 +2737,17 @@ static int filter_truncate(struct obd_export *exp, struct obdo *oa,
                            struct lustre_capa *capa)
 {
         int error;
+        int rc;
         ENTRY;
 
         if (end != OBD_OBJECT_EOF)
                 CERROR("PUNCH not supported, only truncate: end = "LPX64"\n",
                        end);
 
+        rc = filter_verify_capa(OBD_BRW_WRITE, exp, capa);
+        if (rc)
+                RETURN(rc);
+
         CDEBUG(D_INODE, "calling truncate for object "LPU64", valid = "LPU64", "
                "o_size = "LPD64"\n", oa->o_id, oa->o_valid, start);
 
index 258c16c..9a3b813 100644 (file)
@@ -73,10 +73,14 @@ int filter_update_capa_key(struct obd_device *obd, struct lustre_capa_key *key)
 
         if (bkey) {
                 tmp = bkey;
+
+                DEBUG_CAPA_KEY(D_INFO, &tmp->k_key, "filter update");
         } else {
                 OBD_ALLOC(tmp, sizeof(*tmp));
                 if (!tmp)
                         GOTO(out, rc = -ENOMEM);
+
+                DEBUG_CAPA_KEY(D_INFO, &tmp->k_key, "filter new");
         }
 
         /* fields in lustre_capa_key are in cpu order */
@@ -89,29 +93,49 @@ int filter_update_capa_key(struct obd_device *obd, struct lustre_capa_key *key)
         if (!bkey)
                 list_add_tail(&tmp->k_list, &filter->fo_capa_keys);
         spin_unlock(&filter->fo_capa_lock);
-
-        DEBUG_CAPA_KEY(D_INFO, &tmp->k_key, "filter_update_capa_key");
 out:
         RETURN(rc);
 }
 
-int filter_verify_capa(int cmd, struct obd_export *exp, struct inode *inode,
-                       struct lustre_capa *capa)
+int filter_verify_fid(struct obd_export *exp, struct inode *inode,
+                      struct lustre_capa *capa)
+{
+        struct lustre_id fid;
+        int rc;
+
+        if (!capa)
+                return 0;
+
+        ENTRY;
+        rc = fsfilt_get_md(exp->exp_obd, inode, &fid, sizeof(fid), EA_SID);
+        if (rc < 0) {
+                CERROR("get fid from object failed! rc:%d\n", rc);
+                RETURN(rc);
+        } else if (rc > 0) {
+                if (capa->lc_mdsid != id_group(&fid) ||
+                    capa->lc_ino != id_ino(&fid))
+                        RETURN(-EINVAL);
+        }
+
+        RETURN(0);
+}
+
+int
+filter_verify_capa(int cmd, struct obd_export *exp, struct lustre_capa *capa)
 {
         struct obd_device *obd = exp->exp_obd;
         struct filter_obd *filter = &obd->u.filter;
         struct obd_capa *ocapa;
         struct lustre_capa tcapa;
-        struct lustre_id fid;
         struct filter_capa_key *rkey = NULL, *bkey = NULL, *tmp;
         __u8 hmac_key[CAPA_KEY_LEN];
         int rc = 0;
-        ENTRY;
 
         /* capability is disabled */
         if (filter->fo_capa_stat == 0)
                 RETURN(0);
 
+        ENTRY;
         if (capa == NULL)
                 RETURN(-EACCES);
 
@@ -123,16 +147,6 @@ int filter_verify_capa(int cmd, struct obd_export *exp, struct inode *inode,
         if (OBD_FAIL_CHECK(OBD_FAIL_FILTER_VERIFY_CAPA))
                 RETURN(-EACCES);
 
-        rc = fsfilt_get_md(obd, inode, &fid, sizeof(fid), EA_SID);
-        if (rc < 0) {
-                CERROR("get fid from object failed! rc:%d\n", rc);
-                RETURN(rc);
-        } else if (rc > 0) {
-                if (capa->lc_mdsid != id_group(&fid) ||
-                    capa->lc_ino != id_ino(&fid))
-                        RETURN(-EINVAL);
-        }
-
         if (capa_expired(capa))
                 RETURN(-ESTALE);
 
index 98ce1dc..d6140a7 100644 (file)
@@ -200,7 +200,8 @@ static inline lproc_filter_attach_seqstat(struct obd_device *dev) {}
 int filter_init_capa_keys(struct obd_device *obd);
 void filter_free_capa_keys(struct filter_obd *filter);
 int filter_update_capa_key(struct obd_device *obd, struct lustre_capa_key *key);
-int filter_verify_capa(int cmd, struct obd_export *exp, struct inode *inode, 
-                       struct lustre_capa *capa);
+int filter_verify_capa(int cmd, struct obd_export *exp, struct lustre_capa *capa);
+int filter_verify_fid(struct obd_export *exp, struct inode *inode,
+                      struct lustre_capa *capa);
 
 #endif
index 0201ce4..962abb2 100644 (file)
@@ -304,9 +304,11 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
 
         inode = dentry->d_inode; 
 
-        rc = filter_verify_capa(cmd, exp, inode, capa);
-        if (rc)
-                return rc;
+        if (inode) {
+                rc = filter_verify_fid(exp, inode, capa);
+                if (rc)
+                        GOTO(cleanup, rc);
+        }
 
         fsfilt_check_slow(now, obd_timeout, "preprw_read setup");
 
@@ -538,9 +540,9 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
         if (IS_ERR(dentry))
                 GOTO(cleanup, rc = PTR_ERR(dentry));
 
-        rc = filter_verify_capa(cmd, exp, dentry->d_inode, capa);
+        rc = filter_verify_fid(exp, dentry->d_inode, capa);
         if (rc)
-                return rc;
+                GOTO(cleanup, rc);
 
         cleanup_phase = 2;
 
@@ -649,6 +651,12 @@ int filter_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
                   struct niobuf_remote *nb, struct niobuf_local *res,
                   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, capa);
index e1ff6f2..aa07e53 100644 (file)
@@ -25,7 +25,7 @@ int main()
 void lustre_assert_wire_constants(void)
 {
         /* Wire protocol assertions generated by 'wirecheck'
-         * running on Linux localhost.localdomain 2.6.9-1.667 #1 Tue Nov 2 14:41:25 EST 2004 i686 i68
+         * running on Linux localhost.localdomain 2.6.12-1.1372_FC3 #1 Fri Jul 15 00:59:10 EDT 2005 i
          * with gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.fc3) */