Whamcloud - gitweb
use special macro for print time_t, cleanup in includes.
[fs/lustre-release.git] / lustre / obdfilter / filter.c
index bcec97d..f00b738 100644 (file)
@@ -187,7 +187,6 @@ static int filter_export_stats_init(struct obd_device *obd,
                                     void *client_nid)
 {
         struct filter_export_data *fed = &exp->exp_filter_data;
-        struct proc_dir_entry *brw_entry;
         int rc, newnid = 0;
         ENTRY;
 
@@ -210,14 +209,11 @@ static int filter_export_stats_init(struct obd_device *obd,
                         RETURN(-ENOMEM);
 
                 init_brw_stats(tmp->nid_brw_stats);
-
-                brw_entry = create_proc_entry("brw_stats", 0644,
-                                              exp->exp_nid_stats->nid_proc);
-                if (brw_entry == NULL)
-                       RETURN(-ENOMEM);
-
-                brw_entry->proc_fops = &filter_per_nid_stats_fops;
-                brw_entry->data = exp->exp_nid_stats;
+                rc = lprocfs_seq_create(exp->exp_nid_stats->nid_proc, "brw_stats",
+                                        0644, &filter_per_nid_stats_fops,
+                                        exp->exp_nid_stats);
+                if (rc)
+                        CWARN("Error adding the brw_stats file\n");
 
                 rc = lprocfs_init_rw_stats(obd, &exp->exp_nid_stats->nid_stats);
                 if (rc)
@@ -579,7 +575,7 @@ static int filter_init_export(struct obd_export *exp)
 {
         spin_lock_init(&exp->exp_filter_data.fed_lock);
         CFS_INIT_LIST_HEAD(&exp->exp_filter_data.fed_mod_list);
-       
+
         spin_lock(&exp->exp_lock);
         exp->exp_connecting = 1;
         spin_unlock(&exp->exp_lock);
@@ -1647,7 +1643,7 @@ static int filter_intent_policy(struct ldlm_namespace *ns,
                                 struct ldlm_lock **lockp, void *req_cookie,
                                 ldlm_mode_t mode, int flags, void *data)
 {
-        struct list_head rpc_list = CFS_LIST_HEAD_INIT(rpc_list);
+        CFS_LIST_HEAD(rpc_list);
         struct ptlrpc_request *req = req_cookie;
         struct ldlm_lock *lock = *lockp, *l = NULL;
         struct ldlm_resource *res = lock->l_resource;
@@ -2112,8 +2108,15 @@ static int filter_setup(struct obd_device *obd, struct lustre_cfg* lcfg)
                                      "write_bytes", "bytes");
 
                 lproc_filter_attach_seqstat(obd);
-                obd->obd_proc_exports_entry = proc_mkdir("exports",
-                                                         obd->obd_proc_entry);
+                obd->obd_proc_exports_entry = lprocfs_register("exports",
+                                                        obd->obd_proc_entry,
+                                                        NULL, NULL);
+                if (IS_ERR(obd->obd_proc_exports_entry)) {
+                        rc = PTR_ERR(obd->obd_proc_exports_entry);
+                        CERROR("error %d setting up lprocfs for %s\n",
+                               rc, "exports");
+                        obd->obd_proc_exports_entry = NULL;
+                }
         }
         if (obd->obd_proc_exports_entry)
                 lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
@@ -2126,7 +2129,7 @@ static int filter_setup(struct obd_device *obd, struct lustre_cfg* lcfg)
         OBD_PAGE_FREE(page);
 
         if (rc) {
-                remove_proc_entry("clear", obd->obd_proc_exports_entry);
+                lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
                 lprocfs_free_per_client_stats(obd);
                 lprocfs_free_obd_stats(obd);
                 lprocfs_obd_cleanup(obd);
@@ -2389,7 +2392,7 @@ static int filter_cleanup(struct obd_device *obd)
                 }
         }
 
-        remove_proc_entry("clear", obd->obd_proc_exports_entry);
+        lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
         lprocfs_free_per_client_stats(obd);
         lprocfs_free_obd_stats(obd);
         lprocfs_obd_cleanup(obd);
@@ -3131,6 +3134,26 @@ int filter_setattr(struct obd_export *exp, struct obd_info *oinfo,
         if (rc)
                 RETURN(rc);
 
+        /* This would be very bad - accidentally truncating a file when
+         * changing the time or similar - bug 12203. */
+        if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE && 
+            oinfo->oi_policy.l_extent.end != OBD_OBJECT_EOF) {
+                static char mdsinum[48];
+
+                if (oinfo->oi_oa->o_valid & OBD_MD_FLFID)
+                        snprintf(mdsinum, sizeof(mdsinum) - 1,
+                                 " of inode "LPU64"/%u", oinfo->oi_oa->o_fid,
+                                 oinfo->oi_oa->o_generation);
+                else
+                        mdsinum[0] = '\0';
+
+                CERROR("%s: setattr from %s trying to truncate objid "LPU64
+                       " %s\n",
+                       exp->exp_obd->obd_name, obd_export_nid2str(exp),
+                       oinfo->oi_oa->o_id, mdsinum);
+                RETURN(-EPERM);
+        }
+
         dentry = __filter_oa2dentry(exp->exp_obd, oinfo->oi_oa,
                                     __FUNCTION__, 1);
         if (IS_ERR(dentry))