Whamcloud - gitweb
LU-808 llite: deny truncate beyond user rlimit
[fs/lustre-release.git] / lustre / liblustre / super.c
index 4274240..8d03a8e 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",
@@ -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);
@@ -1855,6 +1857,8 @@ llu_fsswop_mount(const char *source,
         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;
 
@@ -1879,7 +1883,7 @@ llu_fsswop_mount(const char *source,
 
         /* generate a string unique to this super, let's try
          the address of the super itself.*/
-        snprintf(cfg.cfg_instance, sizeof(cfg.cfg_instance), "%p", sbi);
+        cfg.cfg_instance = sbi;
 
         /* retrive & parse config log */
         cfg.cfg_uuid = sbi->ll_sb_uuid;
@@ -1894,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(cfg.cfg_instance) + 2);
-        sprintf(osc, "%s-%s", lprof->lp_dt, cfg.cfg_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(cfg.cfg_instance) + 2);
-        sprintf(mdc, "%s-%s", lprof->lp_md, cfg.cfg_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");
@@ -2031,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);
@@ -2045,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;