]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/cifs/inode.c
convert remaining ->clear_inode() to ->evict_inode()
[karo-tx-linux.git] / fs / cifs / inode.c
index 6f0683c689523894cb6fae3edd79181876084d42..b95f4a5af0138dec5c85a0c091053954cef077c0 100644 (file)
@@ -29,6 +29,7 @@
 #include "cifsproto.h"
 #include "cifs_debug.h"
 #include "cifs_fs_sb.h"
+#include "fscache.h"
 
 
 static void cifs_set_ops(struct inode *inode, const bool is_dfs_referral)
@@ -288,7 +289,7 @@ int cifs_get_file_info_unix(struct file *filp)
        struct inode *inode = filp->f_path.dentry->d_inode;
        struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
        struct cifsTconInfo *tcon = cifs_sb->tcon;
-       struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data;
+       struct cifsFileInfo *cfile = filp->private_data;
 
        xid = GetXid();
        rc = CIFSSMBUnixQFileInfo(xid, tcon, cfile->netfid, &find_data);
@@ -515,7 +516,7 @@ int cifs_get_file_info(struct file *filp)
        struct inode *inode = filp->f_path.dentry->d_inode;
        struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
        struct cifsTconInfo *tcon = cifs_sb->tcon;
-       struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data;
+       struct cifsFileInfo *cfile = filp->private_data;
 
        xid = GetXid();
        rc = CIFSSMBQFileInfo(xid, tcon, cfile->netfid, &find_data);
@@ -723,9 +724,14 @@ cifs_find_inode(struct inode *inode, void *opaque)
 {
        struct cifs_fattr *fattr = (struct cifs_fattr *) opaque;
 
+       /* don't match inode with different uniqueid */
        if (CIFS_I(inode)->uniqueid != fattr->cf_uniqueid)
                return 0;
 
+       /* don't match inode of different type */
+       if ((inode->i_mode & S_IFMT) != (fattr->cf_mode & S_IFMT))
+               return 0;
+
        /*
         * uh oh -- it's a directory. We can't use it since hardlinked dirs are
         * verboten. Disable serverino and return it as if it were found, the
@@ -776,6 +782,10 @@ retry_iget5_locked:
                        inode->i_flags |= S_NOATIME | S_NOCMTIME;
                if (inode->i_state & I_NEW) {
                        inode->i_ino = hash;
+#ifdef CONFIG_CIFS_FSCACHE
+                       /* initialize per-inode cache cookie pointer */
+                       CIFS_I(inode)->fscache = NULL;
+#endif
                        unlock_new_inode(inode);
                }
        }
@@ -807,6 +817,11 @@ struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
        if (!inode)
                return ERR_PTR(-ENOMEM);
 
+#ifdef CONFIG_CIFS_FSCACHE
+       /* populate tcon->resource_id */
+       cifs_sb->tcon->resource_id = CIFS_I(inode)->uniqueid;
+#endif
+
        if (rc && cifs_sb->tcon->ipc) {
                cFYI(1, "ipc connection - fake read inode");
                inode->i_mode |= S_IFDIR;
@@ -1568,6 +1583,7 @@ cifs_invalidate_mapping(struct inode *inode)
                        cifs_i->write_behind_rc = rc;
        }
        invalidate_remote_inode(inode);
+       cifs_fscache_reset_inode_cookie(inode);
 }
 
 int cifs_revalidate_file(struct file *filp)
@@ -1780,14 +1796,12 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
 
        xid = GetXid();
 
-       if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) {
-               /* check if we have permission to change attrs */
-               rc = inode_change_ok(inode, attrs);
-               if (rc < 0)
-                       goto out;
-               else
-                       rc = 0;
-       }
+       if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
+               attrs->ia_valid |= ATTR_FORCE;
+
+       rc = inode_change_ok(inode, attrs);
+       if (rc < 0)
+               goto out;
 
        full_path = build_path_from_dentry(direntry);
        if (full_path == NULL) {
@@ -1873,18 +1887,27 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
                                        CIFS_MOUNT_MAP_SPECIAL_CHR);
        }
 
-       if (!rc) {
-               rc = inode_setattr(inode, attrs);
+       if (rc)
+               goto out;
 
-               /* force revalidate when any of these times are set since some
-                  of the fs types (eg ext3, fat) do not have fine enough
-                  time granularity to match protocol, and we do not have a
-                  a way (yet) to query the server fs's time granularity (and
-                  whether it rounds times down).
-               */
-               if (!rc && (attrs->ia_valid & (ATTR_MTIME | ATTR_CTIME)))
-                       cifsInode->time = 0;
+       if ((attrs->ia_valid & ATTR_SIZE) &&
+           attrs->ia_size != i_size_read(inode)) {
+               rc = vmtruncate(inode, attrs->ia_size);
+               if (rc)
+                       goto out;
        }
+
+       setattr_copy(inode, attrs);
+       mark_inode_dirty(inode);
+
+       /* force revalidate when any of these times are set since some
+          of the fs types (eg ext3, fat) do not have fine enough
+          time granularity to match protocol, and we do not have a
+          a way (yet) to query the server fs's time granularity (and
+          whether it rounds times down).
+       */
+       if (attrs->ia_valid & (ATTR_MTIME | ATTR_CTIME))
+               cifsInode->time = 0;
 out:
        kfree(args);
        kfree(full_path);
@@ -1909,14 +1932,13 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
        cFYI(1, "setattr on file %s attrs->iavalid 0x%x",
                 direntry->d_name.name, attrs->ia_valid);
 
-       if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) {
-               /* check if we have permission to change attrs */
-               rc = inode_change_ok(inode, attrs);
-               if (rc < 0) {
-                       FreeXid(xid);
-                       return rc;
-               } else
-                       rc = 0;
+       if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
+               attrs->ia_valid |= ATTR_FORCE;
+
+       rc = inode_change_ok(inode, attrs);
+       if (rc < 0) {
+               FreeXid(xid);
+               return rc;
        }
 
        full_path = build_path_from_dentry(direntry);
@@ -2024,8 +2046,20 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
 
        /* do not need local check to inode_check_ok since the server does
           that */
-       if (!rc)
-               rc = inode_setattr(inode, attrs);
+       if (rc)
+               goto cifs_setattr_exit;
+
+       if ((attrs->ia_valid & ATTR_SIZE) &&
+           attrs->ia_size != i_size_read(inode)) {
+               rc = vmtruncate(inode, attrs->ia_size);
+               if (rc)
+                       goto cifs_setattr_exit;
+       }
+
+       setattr_copy(inode, attrs);
+       mark_inode_dirty(inode);
+       return 0;
+
 cifs_setattr_exit:
        kfree(full_path);
        FreeXid(xid);