]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/fuse/dir.c
[LLC]: Kill static inline llc_addrany
[linux-2.6-omap-h63xx.git] / fs / fuse / dir.c
index 3763757f9fe704f088aa83810289929a33b17ad7..c4807b3fc8a360776bda6f976baebd26b5c9ae92 100644 (file)
@@ -132,6 +132,21 @@ static void fuse_lookup_init(struct fuse_req *req, struct inode *dir,
        req->out.args[0].value = outarg;
 }
 
+static u64 fuse_get_attr_version(struct fuse_conn *fc)
+{
+       u64 curr_version;
+
+       /*
+        * The spin lock isn't actually needed on 64bit archs, but we
+        * don't yet care too much about such optimizations.
+        */
+       spin_lock(&fc->lock);
+       curr_version = fc->attr_version;
+       spin_unlock(&fc->lock);
+
+       return curr_version;
+}
+
 /*
  * Check whether the dentry is still valid
  *
@@ -171,9 +186,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
                        return 0;
                }
 
-               spin_lock(&fc->lock);
-               attr_version = fc->attr_version;
-               spin_unlock(&fc->lock);
+               attr_version = fuse_get_attr_version(fc);
 
                parent = dget_parent(entry);
                fuse_lookup_init(req, parent->d_inode, entry, &outarg);
@@ -256,17 +269,15 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
 
        req = fuse_get_req(fc);
        if (IS_ERR(req))
-               return ERR_PTR(PTR_ERR(req));
+               return ERR_CAST(req);
 
        forget_req = fuse_get_req(fc);
        if (IS_ERR(forget_req)) {
                fuse_put_request(fc, req);
-               return ERR_PTR(PTR_ERR(forget_req));
+               return ERR_CAST(forget_req);
        }
 
-       spin_lock(&fc->lock);
-       attr_version = fc->attr_version;
-       spin_unlock(&fc->lock);
+       attr_version = fuse_get_attr_version(fc);
 
        fuse_lookup_init(req, dir, entry, &outarg);
        request_send(fc, req);
@@ -405,6 +416,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
        fuse_put_request(fc, forget_req);
        d_instantiate(entry, inode);
        fuse_change_entry_timeout(entry, &outentry);
+       fuse_invalidate_attr(dir);
        file = lookup_instantiate_filp(nd, entry, generic_file_open);
        if (IS_ERR(file)) {
                ff->fh = outopen.fh;
@@ -646,6 +658,9 @@ static int fuse_rename(struct inode *olddir, struct dentry *oldent,
        err = req->out.h.error;
        fuse_put_request(fc, req);
        if (!err) {
+               /* ctime changes */
+               fuse_invalidate_attr(oldent->d_inode);
+
                fuse_invalidate_attr(olddir);
                if (olddir != newdir)
                        fuse_invalidate_attr(newdir);
@@ -733,9 +748,7 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
        if (IS_ERR(req))
                return PTR_ERR(req);
 
-       spin_lock(&fc->lock);
-       attr_version = fc->attr_version;
-       spin_unlock(&fc->lock);
+       attr_version = fuse_get_attr_version(fc);
 
        memset(&inarg, 0, sizeof(inarg));
        memset(&outarg, 0, sizeof(outarg));
@@ -775,6 +788,31 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
        return err;
 }
 
+int fuse_update_attributes(struct inode *inode, struct kstat *stat,
+                          struct file *file, bool *refreshed)
+{
+       struct fuse_inode *fi = get_fuse_inode(inode);
+       int err;
+       bool r;
+
+       if (fi->i_time < get_jiffies_64()) {
+               r = true;
+               err = fuse_do_getattr(inode, stat, file);
+       } else {
+               r = false;
+               err = 0;
+               if (stat) {
+                       generic_fillattr(inode, stat);
+                       stat->mode = fi->orig_i_mode;
+               }
+       }
+
+       if (refreshed != NULL)
+               *refreshed = r;
+
+       return err;
+}
+
 /*
  * Calling into a user-controlled filesystem gives the filesystem
  * daemon ptrace-like capabilities over the requester process.  This
@@ -862,18 +900,13 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
         */
        if ((fc->flags & FUSE_DEFAULT_PERMISSIONS) ||
            ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) {
-               struct fuse_inode *fi = get_fuse_inode(inode);
-               if (fi->i_time < get_jiffies_64()) {
-                       err = fuse_do_getattr(inode, NULL, NULL);
-                       if (err)
-                               return err;
-
-                       refreshed = true;
-               }
+               err = fuse_update_attributes(inode, NULL, NULL, &refreshed);
+               if (err)
+                       return err;
        }
 
        if (fc->flags & FUSE_DEFAULT_PERMISSIONS) {
-               int err = generic_permission(inode, mask, NULL);
+               err = generic_permission(inode, mask, NULL);
 
                /* If permission is denied, try to refresh file
                   attributes.  This is also needed, because the root
@@ -935,7 +968,6 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir)
        struct page *page;
        struct inode *inode = file->f_path.dentry->d_inode;
        struct fuse_conn *fc = get_fuse_conn(inode);
-       struct fuse_file *ff = file->private_data;
        struct fuse_req *req;
 
        if (is_bad_inode(inode))
@@ -952,7 +984,7 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir)
        }
        req->num_pages = 1;
        req->pages[0] = page;
-       fuse_read_fill(req, ff, inode, file->f_pos, PAGE_SIZE, FUSE_READDIR);
+       fuse_read_fill(req, file, inode, file->f_pos, PAGE_SIZE, FUSE_READDIR);
        request_send(fc, req);
        nbytes = req->out.args[0].size;
        err = req->out.h.error;
@@ -974,7 +1006,7 @@ static char *read_link(struct dentry *dentry)
        char *link;
 
        if (IS_ERR(req))
-               return ERR_PTR(PTR_ERR(req));
+               return ERR_CAST(req);
 
        link = (char *) __get_free_page(GFP_KERNEL);
        if (!link) {
@@ -1173,22 +1205,12 @@ static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,
                        struct kstat *stat)
 {
        struct inode *inode = entry->d_inode;
-       struct fuse_inode *fi = get_fuse_inode(inode);
        struct fuse_conn *fc = get_fuse_conn(inode);
-       int err;
 
        if (!fuse_allow_task(fc, current))
                return -EACCES;
 
-       if (fi->i_time < get_jiffies_64())
-               err = fuse_do_getattr(inode, stat, NULL);
-       else {
-               err = 0;
-               generic_fillattr(inode, stat);
-               stat->mode = fi->orig_i_mode;
-       }
-
-       return err;
+       return fuse_update_attributes(inode, stat, NULL, NULL);
 }
 
 static int fuse_setxattr(struct dentry *entry, const char *name,