Whamcloud - gitweb
LU-2193 ofd: look up FID to destroy before locking
[fs/lustre-release.git] / lustre / ofd / ofd_obd.c
index 1f8e917..2a05f1d 100644 (file)
@@ -44,7 +44,7 @@
 
 #include "ofd_internal.h"
 #include <obd_cksum.h>
-#include <lquota.h>
+#include <lustre_quota.h>
 
 static int ofd_export_stats_init(struct ofd_device *ofd,
                                 struct obd_export *exp, void *client_nid)
@@ -425,6 +425,14 @@ static int ofd_destroy_export(struct obd_export *exp)
        return 0;
 }
 
+int ofd_postrecov(const struct lu_env *env, struct ofd_device *ofd)
+{
+       struct lu_device *ldev = &ofd->ofd_dt_dev.dd_lu_dev;
+
+       CDEBUG(D_HA, "%s: recovery is over\n", ofd_obd(ofd)->obd_name);
+       return ldev->ld_ops->ldo_recovery_complete(env, ldev);
+}
+
 int ofd_obd_postrecov(struct obd_device *obd)
 {
        struct lu_env            env;
@@ -438,7 +446,8 @@ int ofd_obd_postrecov(struct obd_device *obd)
                RETURN(rc);
        ofd_info_init(&env, obd->obd_self_export);
 
-       rc = ldev->ld_ops->ldo_recovery_complete(&env, ldev);
+       rc = ofd_postrecov(&env, ofd_dev(ldev));
+
        lu_env_fini(&env);
        RETURN(rc);
 }
@@ -942,6 +951,10 @@ static int ofd_destroy_by_fid(const struct lu_env *env,
 
        ENTRY;
 
+       fo = ofd_object_find(env, ofd, fid);
+       if (IS_ERR(fo))
+               RETURN(PTR_ERR(fo));
+
        /* Tell the clients that the object is gone now and that they should
         * throw away any cached pages. */
        ofd_build_resid(fid, &info->fti_resid);
@@ -954,9 +967,6 @@ static int ofd_destroy_by_fid(const struct lu_env *env,
        if (rc == ELDLM_OK)
                ldlm_lock_decref(&lockh, LCK_PW);
 
-       fo = ofd_object_find(env, ofd, fid);
-       if (IS_ERR(fo))
-               RETURN(PTR_ERR(fo));
        LASSERT(fo != NULL);
 
        rc = ofd_object_destroy(env, fo, orphan);
@@ -1004,14 +1014,15 @@ int ofd_destroy(const struct lu_env *env, struct obd_export *exp,
                lrc = ofd_destroy_by_fid(env, ofd, &info->fti_fid, 0);
                if (lrc == -ENOENT) {
                        CDEBUG(D_INODE,
-                              "destroying non-existent object "LPU64"\n",
-                              oa->o_id);
+                              "%s: destroying non-existent object "DFID"\n",
+                              ofd_obd(ofd)->obd_name, PFID(&info->fti_fid));
                        /* rewrite rc with -ENOENT only if it is 0 */
                        if (rc == 0)
                                rc = lrc;
                } else if (lrc != 0) {
-                       CEMERG("error destroying object "LPU64": %d\n",
-                              oa->o_id, rc);
+                       CERROR("%s: error destroying object "DFID": %d\n",
+                              ofd_obd(ofd)->obd_name, PFID(&info->fti_fid),
+                              rc);
                        rc = lrc;
                }
                count--;
@@ -1307,15 +1318,14 @@ static int ofd_sync(const struct lu_env *env, struct obd_export *exp,
                GOTO(out, rc = PTR_ERR(fo));
        }
 
-       ofd_write_lock(env, fo);
        if (!ofd_object_exists(fo))
-               GOTO(unlock, rc = -ENOENT);
+               GOTO(put, rc = -ENOENT);
 
        if (dt_version_get(env, ofd_object_child(fo)) >
            ofd_obd(ofd)->obd_last_committed) {
                rc = dt_object_sync(env, ofd_object_child(fo));
                if (rc)
-                       GOTO(unlock, rc);
+                       GOTO(put, rc);
        }
 
        oinfo->oi_oa->o_valid = OBD_MD_FLID;
@@ -1324,8 +1334,7 @@ static int ofd_sync(const struct lu_env *env, struct obd_export *exp,
 
        ofd_counter_incr(exp, LPROC_OFD_STATS_SYNC, oinfo->oi_jobid, 1);
        EXIT;
-unlock:
-       ofd_write_unlock(env, fo);
+put:
        ofd_object_put(env, fo);
 out:
        return rc;