Whamcloud - gitweb
LU-904 ptlrpc: redo io on -EINPROGRESS
[fs/lustre-release.git] / lustre / liblustre / super.c
index 4279fec..312ce52 100644 (file)
@@ -28,6 +28,8 @@
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -148,11 +150,11 @@ void llu_update_inode(struct inode *inode, struct lustre_md *md)
 
         if (lsm != NULL) {
                 if (lli->lli_smd == NULL) {
-                        cl_inode_init(inode, md);
+                        cl_file_inode_init(inode, md);
                         lli->lli_smd = lsm;
                         lli->lli_maxbytes = lsm->lsm_maxbytes;
-                        if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
-                                lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
+                        if (lli->lli_maxbytes > MAX_LFS_FILESIZE)
+                                lli->lli_maxbytes = MAX_LFS_FILESIZE;
                 } else {
                         if (lov_stripe_md_cmp(lli->lli_smd, lsm)) {
                                 CERROR("lsm mismatch for inode %lld\n",
@@ -287,7 +289,7 @@ int llu_inode_getattr(struct inode *inode, struct obdo *obdo,
                                OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
                                OBD_MD_FLCTIME | OBD_MD_FLGROUP |
                                OBD_MD_FLATIME | OBD_MD_FLEPOCH;
-        obdo_from_inode(oinfo.oi_oa, NULL, &llu_i2info(inode)->lli_fid, 0);
+        obdo_set_parent_fid(oinfo.oi_oa, &llu_i2info(inode)->lli_fid);
         if (sync) {
                 oinfo.oi_oa->o_valid |= OBD_MD_FLFLAGS;
                 oinfo.oi_oa->o_flags |= OBD_FL_SRVLOCK;
@@ -311,8 +313,8 @@ int llu_inode_getattr(struct inode *inode, struct obdo *obdo,
                                OBD_MD_FLSIZE;
 
         obdo_refresh_inode(inode, oinfo.oi_oa, oinfo.oi_oa->o_valid);
-        CDEBUG(D_INODE, "objid "LPX64" size %Lu, blocks %Lu, "
-               "blksize %Lu\n", lli->lli_smd->lsm_object_id,
+        CDEBUG(D_INODE, "objid "LPX64" size %llu, blocks %llu, "
+               "blksize %llu\n", lli->lli_smd->lsm_object_id,
                (long long unsigned)llu_i2stat(inode)->st_size,
                (long long unsigned)llu_i2stat(inode)->st_blocks,
                (long long unsigned)llu_i2stat(inode)->st_blksize);
@@ -767,13 +769,15 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
 
         if (ia_valid & ATTR_SIZE)
                 attr->ia_valid |= ATTR_SIZE;
-        if ((ia_valid & ATTR_SIZE) | 
-            ((ia_valid | ATTR_ATIME | ATTR_ATIME_SET) &&
-             LTIME_S(attr->ia_atime) < LTIME_S(attr->ia_ctime)) ||
-            ((ia_valid | ATTR_MTIME | ATTR_MTIME_SET) &&
-             LTIME_S(attr->ia_mtime) < LTIME_S(attr->ia_ctime)))
-                /* perform truncate and setting mtime/atime to past under PW
-                 * 0:EOF extent lock (new_size:EOF for truncate) */
+        if (ia_valid & (ATTR_SIZE |
+                        ATTR_ATIME | ATTR_ATIME_SET |
+                        ATTR_MTIME | ATTR_MTIME_SET))
+                /* on truncate and utimes send attributes to osts, setting
+                 * mtime/atime to past will be performed under PW 0:EOF extent
+                 * lock (new_size:EOF for truncate)
+                 * it may seem excessive to send mtime/atime updates to osts
+                 * when not setting times to past, but it is necessary due to
+                 * possible time de-synchronization */
                 rc = cl_setattr_ost(inode, attr, NULL);
         EXIT;
 out:
@@ -1140,7 +1144,8 @@ static int llu_statfs(struct llu_sb_info *sbi, struct statfs *sfs)
         /* For now we will always get up-to-date statfs values, but in the
          * future we may allow some amount of caching on the client (e.g.
          * from QOS or lprocfs updates). */
-        rc = llu_statfs_internal(sbi, &osfs, cfs_time_current_64() - CFS_HZ);
+        rc = llu_statfs_internal(sbi, &osfs,
+                                 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS));
         if (rc)
                 return rc;
 
@@ -1846,13 +1851,14 @@ llu_fsswop_mount(const char *source,
         struct lustre_md md;
         class_uuid_t uuid;
         struct config_llog_instance cfg = {0, };
-        char ll_instance[sizeof(sbi) * 2 + 1];
         struct lustre_profile *lprof;
         char *zconf_mgsnid, *zconf_profile;
         char *osc = NULL, *mdc = NULL;
         int async = 1, err = -EINVAL;
         struct obd_connect_data ocd = {0,};
         struct md_op_data op_data = {{0}};
+        /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */
+        const int instlen = sizeof(cfg.cfg_instance) * 2 + 2;
 
         ENTRY;
 
@@ -1877,10 +1883,9 @@ llu_fsswop_mount(const char *source,
 
         /* generate a string unique to this super, let's try
          the address of the super itself.*/
-        sprintf(ll_instance, "%p", sbi);
+        cfg.cfg_instance = sbi;
 
         /* retrive & parse config log */
-        cfg.cfg_instance = ll_instance;
         cfg.cfg_uuid = sbi->ll_sb_uuid;
         err = liblustre_process_log(&cfg, zconf_mgsnid, zconf_profile, 1);
         if (err < 0) {
@@ -1893,11 +1898,11 @@ llu_fsswop_mount(const char *source,
                 CERROR("No profile found: %s\n", zconf_profile);
                 GOTO(out_free, err = -EINVAL);
         }
-        OBD_ALLOC(osc, strlen(lprof->lp_dt) + strlen(ll_instance) + 2);
-        sprintf(osc, "%s-%s", lprof->lp_dt, ll_instance);
+        OBD_ALLOC(osc, strlen(lprof->lp_dt) + instlen + 2);
+        sprintf(osc, "%s-%p", lprof->lp_dt, cfg.cfg_instance);
 
-        OBD_ALLOC(mdc, strlen(lprof->lp_md) + strlen(ll_instance) + 2);
-        sprintf(mdc, "%s-%s", lprof->lp_md, ll_instance);
+        OBD_ALLOC(mdc, strlen(lprof->lp_md) + instlen + 2);
+        sprintf(mdc, "%s-%p", lprof->lp_md, cfg.cfg_instance);
 
         if (!osc) {
                 CERROR("no osc\n");
@@ -1962,7 +1967,7 @@ llu_fsswop_mount(const char *source,
         ocd.ocd_connect_flags = OBD_CONNECT_SRVLOCK | OBD_CONNECT_REQPORTAL |
                                 OBD_CONNECT_VERSION | OBD_CONNECT_TRUNCLOCK |
                                 OBD_CONNECT_FID | OBD_CONNECT_AT |
-                                OBD_CONNECT_FULL20;
+                                OBD_CONNECT_FULL20 | OBD_CONNECT_EINPROGRESS;
 
         ocd.ocd_version = LUSTRE_VERSION_CODE;
         err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL);
@@ -2030,9 +2035,8 @@ llu_fsswop_mount(const char *source,
         ptlrpc_req_finished(request);
 
         CDEBUG(D_SUPER, "LibLustre: %s mounted successfully!\n", source);
-        liblustre_wait_idle();
-
-        return 0;
+        err = 0;
+        goto out_free;
 
 out_inode:
         _sysio_i_gone(root);
@@ -2044,9 +2048,9 @@ out_md:
         obd_disconnect(sbi->ll_md_exp);
 out_free:
         if (osc)
-                OBD_FREE(osc, strlen(osc) + 1);
+                OBD_FREE(osc, strlen(lprof->lp_dt) + instlen + 2);
         if (mdc)
-                OBD_FREE(mdc, strlen(mdc) + 1);
+                OBD_FREE(mdc, strlen(lprof->lp_md) + instlen + 2);
         OBD_FREE(sbi, sizeof(*sbi));
         liblustre_wait_idle();
         return err;