Whamcloud - gitweb
Fixes for remaining POSIX failures, except utime 4.
authoradilger <adilger>
Fri, 18 Jul 2003 00:05:10 +0000 (00:05 +0000)
committeradilger <adilger>
Fri, 18 Jul 2003 00:05:10 +0000 (00:05 +0000)
- set the ATTR_MTIME and ATTR_CTIME flags if truncating, so that we update
  the mtime on either the MDS or OST (depending where we are storing the size)
- check the original ia_valid flag, and not the modified attr->ia_valid flag
  for utime changes
- add a CERROR for ll_truncate() called without a LOV EA (should never happen
  any more)
- do an OST setattr RPC for either MTIME or MTIME_SET flags
- quiet CERRORs for permission problems
- fix another bogus "don't fail if not EPERM" check (we would only have hit
  that if we had data corruption on the wire or on disk)
- allow obdo_refresh_inode() to update IO blocksize.
- fix up some error messages in sanity.sh and sanityN.sh

lustre/llite/llite_lib.c

index 7a844ee..82392f1 100644 (file)
@@ -571,13 +571,17 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
         lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR);
 #endif
 
-        if ((ia_valid & ATTR_SIZE) && attr->ia_size > ll_file_maxbytes(inode)){
-                CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
-                       attr->ia_size, ll_file_maxbytes(inode));
-                RETURN(-EFBIG);
+        if (ia_valid & ATTR_SIZE) {
+                if (attr->ia_size > ll_file_maxbytes(inode)) {
+                        CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
+                               attr->ia_size, ll_file_maxbytes(inode));
+                        RETURN(-EFBIG);
+                }
+
+                attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
         }
 
-        /* We mark all of the fields "set" so the MDS does not re-set them */
+        /* We mark all of the fields "set" so MDS/OST does not re-set them */
         if (ia_valid & ATTR_CTIME) {
                 attr->ia_ctime = now;
                 attr->ia_valid |= ATTR_CTIME_SET;
@@ -609,15 +613,14 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
 
                 if (rc) {
                         ptlrpc_req_finished(request);
-                        if (rc != -EPERM)
-                                CERROR("mdc_setattr fails: err = %d\n", rc);
+                        if (rc != -EPERM && rc != -EACCES)
+                                CERROR("mdc_setattr fails: rc = %d\n", rc);
                         RETURN(rc);
                 }
 
                 rc = mdc_req2lustre_md(request, 0, &sbi->ll_osc_conn, &md);
-                if (rc && rc != -EPERM) {
+                if (rc) {
                         ptlrpc_req_finished(request);
-                        CERROR("mdc_setattr fails: err = %d\n", rc);
                         RETURN(rc);
                 }
                 ll_update_inode(inode, md.body, md.lsm);
@@ -638,10 +641,12 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                                 if (current->fsuid != inode->i_uid &&
                                     (rc = permission(inode, MAY_WRITE)) != 0)
                                         RETURN(rc);
+                        } else {
+                               /* from inode_change_ok() */
+                               if (current->fsuid != inode->i_uid &&
+                                   !capable(CAP_FOWNER))
+                                       RETURN(-EPERM);
                         }
-
-                        if ((rc = inode_change_ok(inode, attr)))
-                                RETURN(rc);
                 }
 
                 /* Won't invoke vmtruncate, as we already cleared ATTR_SIZE */
@@ -665,7 +670,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                  * nodes through dirtying and writeback of final cached
                  * pages.  This last one is especially bad for racing
                  * o_append users on other nodes. */
-                rc = ll_extent_lock_no_validate(NULL, inode, lsm, LCK_PW, 
+                rc = ll_extent_lock_no_validate(NULL, inode, lsm, LCK_PW,
                                                  &extent, &lockh);
                 if (rc != ELDLM_OK) {
                         if (rc > 0)
@@ -675,10 +680,10 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
 
                 rc = vmtruncate(inode, attr->ia_size);
                 if (rc == 0)
-                        set_bit(LLI_F_HAVE_SIZE_LOCK, 
+                        set_bit(LLI_F_HAVE_SIZE_LOCK,
                                 &ll_i2info(inode)->lli_flags);
 
-                /* unlock now as we don't mind others file lockers racing with 
+                /* unlock now as we don't mind others file lockers racing with
                  * the mds updates below? */
                 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
                 if (err) {
@@ -686,7 +691,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                         if (!rc)
                                 rc = err;
                 }
-        } else if (ia_valid & ATTR_MTIME_SET) {
+        } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
                 struct obdo oa;
 
                 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",