]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/cifs/inode.c
[CIFS] Do not overwrite aops
[linux-2.6-omap-h63xx.git] / fs / cifs / inode.c
index b21038b99fc27c6859ab165f5df7645fd5a6d453..b88147c1dc27f0df435b6251376a73b7dfc531cb 100644 (file)
@@ -41,7 +41,7 @@ int cifs_get_inode_info_unix(struct inode **pinode,
        char *tmp_path;
 
        pTcon = cifs_sb->tcon;
-       cFYI(1, ("Getting info on %s ", search_path));
+       cFYI(1, ("Getting info on %s", search_path));
        /* could have done a find first instead but this returns more info */
        rc = CIFSSMBUnixQPathInfo(xid, pTcon, search_path, &findData,
                                  cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
@@ -97,9 +97,9 @@ int cifs_get_inode_info_unix(struct inode **pinode,
                inode = *pinode;
                cifsInfo = CIFS_I(inode);
 
-               cFYI(1, ("Old time %ld ", cifsInfo->time));
+               cFYI(1, ("Old time %ld", cifsInfo->time));
                cifsInfo->time = jiffies;
-               cFYI(1, ("New time %ld ", cifsInfo->time));
+               cFYI(1, ("New time %ld", cifsInfo->time));
                /* this is ok to set on every inode revalidate */
                atomic_set(&cifsInfo->inUse,1);
 
@@ -163,9 +163,9 @@ int cifs_get_inode_info_unix(struct inode **pinode,
 
                if (num_of_bytes < end_of_file)
                        cFYI(1, ("allocation size less than end of file"));
-               cFYI(1,
-                    ("Size %ld and blocks %ld",
-                     (unsigned long) inode->i_size, inode->i_blocks));
+               cFYI(1, ("Size %ld and blocks %llu",
+                       (unsigned long) inode->i_size,
+                       (unsigned long long)inode->i_blocks));
                if (S_ISREG(inode->i_mode)) {
                        cFYI(1, ("File inode"));
                        inode->i_op = &cifs_file_inode_ops;
@@ -180,11 +180,12 @@ int cifs_get_inode_info_unix(struct inode **pinode,
                        else /* not direct, send byte range locks */ 
                                inode->i_fop = &cifs_file_ops;
 
-                       inode->i_data.a_ops = &cifs_addr_ops;
                        /* check if server can support readpages */
                        if(pTcon->ses->server->maxBuf < 
-                           4096 + MAX_CIFS_HDR_SIZE)
-                               inode->i_data.a_ops->readpages = NULL;
+                           PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
+                               inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
+                       else
+                               inode->i_data.a_ops = &cifs_addr_ops;
                } else if (S_ISDIR(inode->i_mode)) {
                        cFYI(1, ("Directory inode"));
                        inode->i_op = &cifs_dir_inode_ops;
@@ -421,23 +422,23 @@ int cifs_get_inode_info(struct inode **pinode,
                inode = *pinode;
                cifsInfo = CIFS_I(inode);
                cifsInfo->cifsAttrs = attr;
-               cFYI(1, ("Old time %ld ", cifsInfo->time));
+               cFYI(1, ("Old time %ld", cifsInfo->time));
                cifsInfo->time = jiffies;
-               cFYI(1, ("New time %ld ", cifsInfo->time));
+               cFYI(1, ("New time %ld", cifsInfo->time));
 
                /* blksize needs to be multiple of two. So safer to default to
                blksize and blkbits set in superblock so 2**blkbits and blksize
                will match rather than setting to:
                (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/
 
-               /* Linux can not store file creation time unfortunately so we ignore it */
+               /* Linux can not store file creation time so ignore it */
                inode->i_atime =
                    cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime));
                inode->i_mtime =
                    cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime));
                inode->i_ctime =
                    cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
-               cFYI(0, ("Attributes came in as 0x%x ", attr));
+               cFYI(0, ("Attributes came in as 0x%x", attr));
 
                /* set default mode. will override for dirs below */
                if (atomic_read(&cifsInfo->inUse) == 0)
@@ -519,10 +520,11 @@ int cifs_get_inode_info(struct inode **pinode,
                        else /* not direct, send byte range locks */
                                inode->i_fop = &cifs_file_ops;
 
-                       inode->i_data.a_ops = &cifs_addr_ops;
                        if(pTcon->ses->server->maxBuf < 
-                            4096 + MAX_CIFS_HDR_SIZE)
-                               inode->i_data.a_ops->readpages = NULL;
+                            PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
+                               inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
+                       else
+                               inode->i_data.a_ops = &cifs_addr_ops;
                } else if (S_ISDIR(inode->i_mode)) {
                        cFYI(1, ("Directory inode"));
                        inode->i_op = &cifs_dir_inode_ops;
@@ -565,18 +567,21 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
        struct cifsInodeInfo *cifsInode;
        FILE_BASIC_INFO *pinfo_buf;
 
-       cFYI(1, ("cifs_unlink, inode = 0x%p with ", inode));
+       cFYI(1, ("cifs_unlink, inode = 0x%p", inode));
 
        xid = GetXid();
 
-       cifs_sb = CIFS_SB(inode->i_sb);
+       if(inode)
+               cifs_sb = CIFS_SB(inode->i_sb);
+       else
+               cifs_sb = CIFS_SB(direntry->d_sb);
        pTcon = cifs_sb->tcon;
 
        /* Unlink can be called from rename so we can not grab the sem here
           since we deadlock otherwise */
-/*     down(&direntry->d_sb->s_vfs_rename_sem);*/
+/*     mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);*/
        full_path = build_path_from_dentry(direntry);
-/*     up(&direntry->d_sb->s_vfs_rename_sem);*/
+/*     mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);*/
        if (full_path == NULL) {
                FreeXid(xid);
                return -ENOMEM;
@@ -692,9 +697,11 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
                                           when needed */
                direntry->d_inode->i_ctime = current_fs_time(inode->i_sb);
        }
-       inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);
-       cifsInode = CIFS_I(inode);
-       cifsInode->time = 0;    /* force revalidate of dir as well */
+       if(inode) {
+               inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);
+               cifsInode = CIFS_I(inode);
+               cifsInode->time = 0;    /* force revalidate of dir as well */
+       }
 
        kfree(full_path);
        FreeXid(xid);
@@ -717,9 +724,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
        cifs_sb = CIFS_SB(inode->i_sb);
        pTcon = cifs_sb->tcon;
 
-       down(&inode->i_sb->s_vfs_rename_sem);
        full_path = build_path_from_dentry(direntry);
-       up(&inode->i_sb->s_vfs_rename_sem);
        if (full_path == NULL) {
                FreeXid(xid);
                return -ENOMEM;
@@ -728,7 +733,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
        rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls,
                          cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
        if (rc) {
-               cFYI(1, ("cifs_mkdir returned 0x%x ", rc));
+               cFYI(1, ("cifs_mkdir returned 0x%x", rc));
                d_drop(direntry);
        } else {
                inode->i_nlink++;
@@ -795,16 +800,14 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
        char *full_path = NULL;
        struct cifsInodeInfo *cifsInode;
 
-       cFYI(1, ("cifs_rmdir, inode = 0x%p with ", inode));
+       cFYI(1, ("cifs_rmdir, inode = 0x%p", inode));
 
        xid = GetXid();
 
        cifs_sb = CIFS_SB(inode->i_sb);
        pTcon = cifs_sb->tcon;
 
-       down(&inode->i_sb->s_vfs_rename_sem);
        full_path = build_path_from_dentry(direntry);
-       up(&inode->i_sb->s_vfs_rename_sem);
        if (full_path == NULL) {
                FreeXid(xid);
                return -ENOMEM;
@@ -1120,7 +1123,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
 
        xid = GetXid();
 
-       cFYI(1, ("In cifs_setattr, name = %s attrs->iavalid 0x%x ",
+       cFYI(1, ("setattr on file %s attrs->iavalid 0x%x",
                 direntry->d_name.name, attrs->ia_valid));
 
        cifs_sb = CIFS_SB(direntry->d_inode->i_sb);
@@ -1136,9 +1139,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
                        rc = 0;
        }
                
-       down(&direntry->d_sb->s_vfs_rename_sem);
        full_path = build_path_from_dentry(direntry);
-       up(&direntry->d_sb->s_vfs_rename_sem);
        if (full_path == NULL) {
                FreeXid(xid);
                return -ENOMEM;
@@ -1158,6 +1159,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
                   when the local oplock break takes longer to flush
                   writebehind data than the SMB timeout for the SetPathInfo
                   request would allow */
+
                open_file = find_writable_file(cifsInode);
                if (open_file) {
                        __u16 nfid = open_file->netfid;
@@ -1290,7 +1292,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
                it may be useful to Windows - but we do
                not want to set ctime unless some other
                timestamp is changing */
-               cFYI(1, ("CIFS - CTIME changed "));
+               cFYI(1, ("CIFS - CTIME changed"));
                time_buf.ChangeTime =
                    cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_ctime));
        } else
@@ -1357,7 +1359,7 @@ cifs_setattr_exit:
 
 void cifs_delete_inode(struct inode *inode)
 {
-       cFYI(1, ("In cifs_delete_inode, inode = 0x%p ", inode));
+       cFYI(1, ("In cifs_delete_inode, inode = 0x%p", inode));
        /* may have to add back in if and when safe distributed caching of
           directories added e.g. via FindNotify */
 }