From: fanyong Date: Thu, 31 Aug 2006 16:27:00 +0000 (+0000) Subject: Initialize the x(a/m/c)time for new file, X-Git-Tag: v1_8_0_110~486^2~1051 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7365f8eb69392d740fa3bb2a1e9d2627e16f1550;p=fs%2Flustre-release.git Initialize the x(a/m/c)time for new file, otherwise we will get file time of 1970-1-1. --- diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 93f88bf..5498de7 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -1451,6 +1451,16 @@ static int mdd_lookup(const struct lu_context *ctxt, struct md_object *pobj, RETURN(rc); } +static void mdd_init_attr(struct lu_attr *attr) +{ + time_t now = CURRENT_SECONDS; + + attr->la_valid |= (LA_ATIME | LA_MTIME | LA_CTIME); + attr->la_atime = now; + attr->la_mtime = now; + attr->la_ctime = now; +} + static int __mdd_object_initialize(const struct lu_context *ctxt, const struct lu_fid *pfid, struct mdd_object *child, @@ -1465,6 +1475,7 @@ static int __mdd_object_initialize(const struct lu_context *ctxt, * (2) maybe, the child attributes should be set in OSD when creation. */ + mdd_init_attr(&ma->ma_attr); rc = mdd_attr_set_internal(ctxt, child, &ma->ma_attr, handle); if (rc != 0) RETURN(rc);