]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
orangefs: set i_size on new symlink
authorMartin Brandenburg <martin@omnibond.com>
Thu, 31 May 2018 16:36:58 +0000 (16:36 +0000)
committerMike Marshall <hubcap@omnibond.com>
Fri, 1 Jun 2018 18:49:46 +0000 (14:49 -0400)
As long as a symlink inode remains in-core, the destination (and
therefore size) will not be re-fetched from the server, as it cannot
change.  The original implementation of the attribute cache assumed that
setting the expiry time in the past was sufficient to cause a re-fetch
of all attributes on the next getattr.  That does not work in this case.

The bug manifested itself as follows.  When the command sequence

touch foo; ln -s foo bar; ls -l bar

is run, the output was

lrwxrwxrwx. 1 fedora fedora 4906 Apr 24 19:10 bar -> foo

However, after a re-mount, ls -l bar produces

lrwxrwxrwx. 1 fedora fedora    3 Apr 24 19:10 bar -> foo

After this commit, even before a re-mount, the output is

lrwxrwxrwx. 1 fedora fedora    3 Apr 24 19:10 bar -> foo

Reported-by: Becky Ligon <ligon@clemson.edu>
Signed-off-by: Martin Brandenburg <martin@omnibond.com>
Fixes: 71680c18c8f2 ("orangefs: Cache getattr results.")
Cc: stable@vger.kernel.org
Cc: hubcap@omnibond.com
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
fs/orangefs/namei.c

index 1b5707c44c3f61dcf54fc6f2bc7901b420d2e322..e026bee02a662fb5e4bc4c36e4bde7a16fb4442e 100644 (file)
@@ -326,6 +326,13 @@ static int orangefs_symlink(struct inode *dir,
                ret = PTR_ERR(inode);
                goto out;
        }
+       /*
+        * This is necessary because orangefs_inode_getattr will not
+        * re-read symlink size as it is impossible for it to change.
+        * Invalidating the cache does not help.  orangefs_new_inode
+        * does not set the correct size (it does not know symname).
+        */
+       inode->i_size = strlen(symname);
 
        gossip_debug(GOSSIP_NAME_DEBUG,
                     "Assigned symlink inode new number of %pU\n",