cifs_sb = CIFS_SB(inode->i_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);*/
full_path = build_path_from_dentry(direntry);
-
+/* up(&direntry->d_sb->s_vfs_rename_sem);*/
+ if(full_path == NULL) {
+ FreeXid(xid);
+ return -ENOMEM;
+ }
rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb->local_nls);
if (!rc) {
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;
+ }
/* BB add setting the equivalent of mode via CreateX w/ACLs */
rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls);
if (rc) {
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;
+ }
rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb->local_nls);
different share. Might eventually add support for this */
}
+ /* we already have the rename sem so we do not need
+ to grab it again here to protect the path integrity */
fromName = build_path_from_dentry(source_direntry);
toName = build_path_from_dentry(target_direntry);
+ if((fromName == NULL) || (toName == NULL)) {
+ rc = -ENOMEM;
+ goto cifs_rename_exit;
+ }
rc = CIFSSMBRename(xid, pTcon, fromName, toName,
cifs_sb_source->local_nls);
CIFSSMBClose(xid, pTcon, netfid);
}
}
+
+cifs_rename_exit:
if (fromName)
kfree(fromName);
if (toName)
cifs_sb = CIFS_SB(direntry->d_sb);
+ /* can not safely grab the rename sem here if
+ rename calls revalidate since that would deadlock */
full_path = build_path_from_dentry(direntry);
+ if(full_path == NULL) {
+ FreeXid(xid);
+ return -ENOMEM;
+ }
cFYI(1,
("Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld jiffies %ld",
full_path, direntry->d_inode,
}
}
-
+ /* can not grab this sem since kernel filesys locking
+ documentation indicates i_sem may be taken by the kernel
+ on lookup and rename which could deadlock if we grab
+ the i_sem here as well */
+/* down(&direntry->d_inode->i_sem);*/
/* need to write out dirty pages here */
- down(&direntry->d_inode->i_sem);
if(direntry->d_inode->i_mapping) {
/* do we need to lock inode until after invalidate completes below? */
filemap_fdatawrite(direntry->d_inode->i_mapping);
invalidate_remote_inode(direntry->d_inode);
}
}
-
-
- up(&direntry->d_inode->i_sem);
+/* up(&direntry->d_inode->i_sem);*/
if (full_path)
kfree(full_path);
cifs_sb = CIFS_SB(direntry->d_inode->i_sb);
pTcon = cifs_sb->tcon;
+ 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;
+ }
cifsInode = CIFS_I(direntry->d_inode);
/* BB check if we need to refresh inode from server now ? BB */