patch for early truncation

Nickolai Zeldovich kolya at mit.edu
Tue Nov 27 09:48:50 CET 2001


I ran into the following bug just now:

  machine-A% echo a > ~/foo
  machine-A% cat ~/foo
  a

  machine-B% fs sa ~ $USER rla

  machine-A% echo a > ~/foo
  foo: Permission denied.
  machine-A% cat ~/foo
  machine-A% ls -ld ~/foo
  -rw-r--r--  1 kolya  wheel  2 Nov 27 03:42 foo

The problem seems to be that arla's access cache says I should be
able to write to foo, and xfs sends a putattr to arlad.  In turn,
arlad first truncates the local cache file, and then tries to send
the StoreStatus, which fails.  This seems like the wrong order to
do it in.  The patch below fixes this particular problem, and gives
the expected behavior:  even though we were unable to write to foo,
it still contains the prior data.

-- kolya

--- arlad/messages.c	2001/10/19 04:25:52	1.231.2.12
+++ arlad/messages.c	2001/11/27 08:41:37
@@ -570,12 +570,10 @@
      }
 
      do {
-	 res.res = 0;
-	 if (XA_VALID_SIZE(&h->attr))
-	     res = cm_ftruncate (*fid, h->attr.xa_size, ce);
+	 res = cm_setattr(*fid, &status, ce);
 
-	 if (res.res == 0)
-	     res = cm_setattr(*fid, &status, ce);
+	 if (res.res == 0 && XA_VALID_SIZE(&h->attr))
+	     res = cm_ftruncate (*fid, h->attr.xa_size, ce);
 
 	 if (res.res)
 	     ret = res.error;





More information about the Arla-drinkers mailing list