Shirish Pargaonkar noted:
With cifsacl mount option, when a file is created on the Windows server,
exclusive oplock is broken right away because the get cifs acl code
again opens the file to obtain security descriptor.
The client does not have the newly created file handle or inode in any
of its lists yet so it does not respond to oplock break and server waits for
its duration and then responds to the second open. This slows down file
creation signficantly. The fix is to pass the file descriptor to the get
cifsacl code wherever available so that get cifs acl code does not send
second open (NT Create ANDX) and oplock is not broken.
CC: Shirish Pargaonkar <shirishp@us.ibm.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
- * Copyright (C) International Business Machines Corp., 2007
+ * Copyright (C) International Business Machines Corp., 2007,2008
* Author(s): Steve French (sfrench@us.ibm.com)
*
* Contains the routines for mapping CIFS/NTFS ACLs
* Author(s): Steve French (sfrench@us.ibm.com)
*
* Contains the routines for mapping CIFS/NTFS ACLs
/* Retrieve an ACL from the server */
static struct cifs_ntsd *get_cifs_acl(u32 *pacllen, struct inode *inode,
/* Retrieve an ACL from the server */
static struct cifs_ntsd *get_cifs_acl(u32 *pacllen, struct inode *inode,
+ const char *path, const __u16 *pfid)
- struct cifsFileInfo *open_file;
+ struct cifsFileInfo *open_file = NULL;
int unlock_file = FALSE;
int xid;
int rc = -EIO;
int unlock_file = FALSE;
int xid;
int rc = -EIO;
return NULL;
xid = GetXid();
return NULL;
xid = GetXid();
- open_file = find_readable_file(CIFS_I(inode));
+ if (pfid == NULL)
+ open_file = find_readable_file(CIFS_I(inode));
+ else
+ fid = *pfid;
+
sb = inode->i_sb;
if (sb == NULL) {
FreeXid(xid);
sb = inode->i_sb;
if (sb == NULL) {
FreeXid(xid);
if (open_file) {
unlock_file = TRUE;
fid = open_file->netfid;
if (open_file) {
unlock_file = TRUE;
fid = open_file->netfid;
+ } else if (pfid == NULL) {
int oplock = FALSE;
/* open file */
rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
int oplock = FALSE;
/* open file */
rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, &pntsd, pacllen);
cFYI(1, ("GetCIFSACL rc = %d ACL len %d", rc, *pacllen));
rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, &pntsd, pacllen);
cFYI(1, ("GetCIFSACL rc = %d ACL len %d", rc, *pacllen));
- if (unlock_file == TRUE)
+ if (unlock_file == TRUE) /* find_readable_file increments ref count */
atomic_dec(&open_file->wrtPending);
atomic_dec(&open_file->wrtPending);
+ else if (pfid == NULL) /* if opened above we have to close the handle */
CIFSSMBClose(xid, cifs_sb->tcon, fid);
CIFSSMBClose(xid, cifs_sb->tcon, fid);
+ /* else handle was passed in by caller */
FreeXid(xid);
return pntsd;
FreeXid(xid);
return pntsd;
}
/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
}
/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
-void acl_to_uid_mode(struct inode *inode, const char *path)
+void acl_to_uid_mode(struct inode *inode, const char *path, const __u16 *pfid)
{
struct cifs_ntsd *pntsd = NULL;
u32 acllen = 0;
int rc = 0;
cFYI(DBG2, ("converting ACL to mode for %s", path));
{
struct cifs_ntsd *pntsd = NULL;
u32 acllen = 0;
int rc = 0;
cFYI(DBG2, ("converting ACL to mode for %s", path));
- pntsd = get_cifs_acl(&acllen, inode, path);
+ pntsd = get_cifs_acl(&acllen, inode, path, pfid);
/* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
if (pntsd)
/* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
if (pntsd)
cFYI(DBG2, ("set ACL from mode for %s", path));
/* Get the security descriptor */
cFYI(DBG2, ("set ACL from mode for %s", path));
/* Get the security descriptor */
- pntsd = get_cifs_acl(&acllen, inode, path);
+ pntsd = get_cifs_acl(&acllen, inode, path, NULL);
/* Add three ACEs for owner, group, everyone getting rid of
other ACEs as chmod disables ACEs and set the security descriptor */
/* Add three ACEs for owner, group, everyone getting rid of
other ACEs as chmod disables ACEs and set the security descriptor */
extern int cifs_get_inode_info(struct inode **pinode,
const unsigned char *search_path,
FILE_ALL_INFO * pfile_info,
extern int cifs_get_inode_info(struct inode **pinode,
const unsigned char *search_path,
FILE_ALL_INFO * pfile_info,
- struct super_block *sb, int xid);
+ struct super_block *sb, int xid, const __u16 *pfid);
extern int cifs_get_inode_info_unix(struct inode **pinode,
const unsigned char *search_path,
struct super_block *sb, int xid);
extern int cifs_get_inode_info_unix(struct inode **pinode,
const unsigned char *search_path,
struct super_block *sb, int xid);
-extern void acl_to_uid_mode(struct inode *inode, const char *search_path);
+extern void acl_to_uid_mode(struct inode *inode, const char *path,
+ const __u16 *pfid);
extern int mode_to_acl(struct inode *inode, const char *path, __u64);
extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
extern int mode_to_acl(struct inode *inode, const char *path, __u64);
extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
inode->i_sb, xid);
else {
rc = cifs_get_inode_info(&newinode, full_path,
inode->i_sb, xid);
else {
rc = cifs_get_inode_info(&newinode, full_path,
- buf, inode->i_sb, xid);
+ buf, inode->i_sb, xid,
+ &fileHandle);
if (newinode) {
newinode->i_mode = mode;
if ((oplock & CIFS_CREATE_ACTION) &&
if (newinode) {
newinode->i_mode = mode;
if ((oplock & CIFS_CREATE_ACTION) &&
parent_dir_inode->i_sb, xid);
else
rc = cifs_get_inode_info(&newInode, full_path, NULL,
parent_dir_inode->i_sb, xid);
else
rc = cifs_get_inode_info(&newInode, full_path, NULL,
- parent_dir_inode->i_sb, xid);
+ parent_dir_inode->i_sb, xid, NULL);
if ((rc == 0) && (newInode != NULL)) {
if (pTcon->nocase)
if ((rc == 0) && (newInode != NULL)) {
if (pTcon->nocase)
full_path, inode->i_sb, xid);
else
rc = cifs_get_inode_info(&file->f_path.dentry->d_inode,
full_path, inode->i_sb, xid);
else
rc = cifs_get_inode_info(&file->f_path.dentry->d_inode,
- full_path, buf, inode->i_sb, xid);
+ full_path, buf, inode->i_sb, xid, NULL);
if ((*oplock & 0xF) == OPLOCK_EXCLUSIVE) {
pCifsInode->clientCanCacheAll = TRUE;
if ((*oplock & 0xF) == OPLOCK_EXCLUSIVE) {
pCifsInode->clientCanCacheAll = TRUE;
else
rc = cifs_get_inode_info(&inode,
full_path, NULL, inode->i_sb,
else
rc = cifs_get_inode_info(&inode,
full_path, NULL, inode->i_sb,
} /* else we are writing out data to server already
and could deadlock if we tried to flush data, and
since we do not know if we have data that would
} /* else we are writing out data to server already
and could deadlock if we tried to flush data, and
since we do not know if we have data that would
int cifs_get_inode_info(struct inode **pinode,
const unsigned char *search_path, FILE_ALL_INFO *pfindData,
int cifs_get_inode_info(struct inode **pinode,
const unsigned char *search_path, FILE_ALL_INFO *pfindData,
- struct super_block *sb, int xid)
+ struct super_block *sb, int xid, const __u16 *pfid)
{
int rc = 0;
struct cifsTconInfo *pTcon;
{
int rc = 0;
struct cifsTconInfo *pTcon;
/* fill in 0777 bits from ACL */
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
cFYI(1, ("Getting mode bits from ACL"));
/* fill in 0777 bits from ACL */
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
cFYI(1, ("Getting mode bits from ACL"));
- acl_to_uid_mode(inode, search_path);
+ acl_to_uid_mode(inode, search_path, pfid);
}
#endif
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
}
#endif
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
if (cifs_sb->tcon->unix_ext)
rc = cifs_get_inode_info_unix(&inode, "", inode->i_sb, xid);
else
if (cifs_sb->tcon->unix_ext)
rc = cifs_get_inode_info_unix(&inode, "", inode->i_sb, xid);
else
- rc = cifs_get_inode_info(&inode, "", NULL, inode->i_sb, xid);
+ rc = cifs_get_inode_info(&inode, "", NULL, inode->i_sb, xid,
+ NULL);
if (rc && cifs_sb->tcon->ipc) {
cFYI(1, ("ipc connection - fake read inode"));
inode->i_mode |= S_IFDIR;
if (rc && cifs_sb->tcon->ipc) {
cFYI(1, ("ipc connection - fake read inode"));
inode->i_mode |= S_IFDIR;
inode->i_sb, xid);
else
rc = cifs_get_inode_info(&newinode, full_path, NULL,
inode->i_sb, xid);
else
rc = cifs_get_inode_info(&newinode, full_path, NULL,
+ inode->i_sb, xid, NULL);
if (pTcon->nocase)
direntry->d_op = &cifs_ci_dentry_ops;
if (pTcon->nocase)
direntry->d_op = &cifs_ci_dentry_ops;
}
} else {
rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL,
}
} else {
rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL,
+ direntry->d_sb, xid, NULL);
if (rc) {
cFYI(1, ("error on getting revalidate info %d", rc));
/* if (rc != -ENOENT)
if (rc) {
cFYI(1, ("error on getting revalidate info %d", rc));
/* if (rc != -ENOENT)
inode->i_sb, xid);
else
rc = cifs_get_inode_info(&newinode, full_path, NULL,
inode->i_sb, xid);
else
rc = cifs_get_inode_info(&newinode, full_path, NULL,
+ inode->i_sb, xid, NULL);
if (rc != 0) {
cFYI(1, ("Create symlink ok, getinodeinfo fail rc = %d",
if (rc != 0) {
cFYI(1, ("Create symlink ok, getinodeinfo fail rc = %d",