Commit a9f29eae authored by Pavel Shilovsky's avatar Pavel Shilovsky

Bugfixes

Add mmap for nobrl direct shares Fix bugs CentOS 5.{2,3} Code style fixes
parent 487d84ce
......@@ -834,7 +834,7 @@ struct file_operations cifs_file_nobrl_ops = {
};
struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -842,6 +842,7 @@ struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
.sendfile = generic_file_sendfile, /* BB removeme BB */
#else
......
......@@ -719,7 +719,7 @@ const struct file_operations cifs_file_nobrl_ops = {
};
const struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -727,6 +727,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.ioctl = cifs_ioctl,
......
......@@ -718,7 +718,7 @@ const struct file_operations cifs_file_nobrl_ops = {
};
const struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -726,6 +726,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.ioctl = cifs_ioctl,
......
......@@ -756,7 +756,7 @@ const struct file_operations cifs_file_nobrl_ops = {
};
const struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -764,6 +764,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.ioctl = cifs_ioctl,
......
......@@ -783,7 +783,7 @@ const struct file_operations cifs_file_nobrl_ops = {
};
const struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -791,6 +791,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl = cifs_ioctl,
......
......@@ -784,7 +784,7 @@ const struct file_operations cifs_file_nobrl_ops = {
};
const struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -792,6 +792,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl = cifs_ioctl,
......
......@@ -822,7 +822,7 @@ const struct file_operations cifs_file_nobrl_ops = {
};
const struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -830,6 +830,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl = cifs_ioctl,
......
......@@ -836,7 +836,7 @@ const struct file_operations cifs_file_nobrl_ops = {
};
const struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -844,6 +844,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl = cifs_ioctl,
......
......@@ -837,7 +837,7 @@ const struct file_operations cifs_file_nobrl_ops = {
};
const struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -845,6 +845,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl = cifs_ioctl,
......
......@@ -849,7 +849,7 @@ const struct file_operations cifs_file_nobrl_ops = {
};
const struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -857,6 +857,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.unlocked_ioctl = cifs_ioctl,
......
......@@ -594,14 +594,15 @@ cifs_get_sb(struct file_system_type *fs_type,
#endif
}
static ssize_t cifs_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
static ssize_t cifs_sync_read(struct file *filp, char __user *buf,
size_t len, loff_t *ppos)
{
int retval, read, posix_locking = 0;
struct file_lock pfLock;
struct cifsInodeInfo *cifsInode;
struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *tcon;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18)
cifs_sb = CIFS_SB(filp->f_path.dentry->d_sb);
tcon = cifs_sb->tcon;
if ((tcon->ses->capabilities & CAP_UNIX) &&
......@@ -621,7 +622,31 @@ static ssize_t cifs_sync_read(struct file *filp, char __user *buf, size_t len, l
if (cifsInode == NULL)
return -ENOENT;
if (!CIFS_I(filp->f_path.dentry->d_inode)->clientCanCacheRead && !posix_locking) {
if (!CIFS_I(filp->f_path.dentry->d_inode)->clientCanCacheRead
&& !posix_locking) {
#else
cifs_sb = CIFS_SB(filp->f_dentry->d_sb);
tcon = cifs_sb->tcon;
if ((tcon->ses->capabilities & CAP_UNIX) &&
(CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
posix_locking = 1;
retval = cifs_revalidate(filp->f_dentry);
if (retval < 0)
return (ssize_t)retval;
memset(&pfLock, 0, sizeof(pfLock));
pfLock.fl_type = F_RDLCK;
pfLock.fl_start = *ppos;
pfLock.fl_end = *ppos+len;
cifsInode = CIFS_I(filp->f_dentry->d_inode);
if (cifsInode == NULL)
return -ENOENT;
if (!CIFS_I(filp->f_dentry->d_inode)->clientCanCacheRead
&& !posix_locking) {
#endif
retval = cifs_lock(filp, F_GETLK, &pfLock);
if (retval < 0)
return (ssize_t)retval;
......@@ -842,7 +867,7 @@ const struct file_operations cifs_file_nobrl_ops = {
};
const struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -850,6 +875,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
.sendfile = generic_file_sendfile, /* BB removeme BB */
#else
......
......@@ -856,8 +856,30 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
} else {
/* if rc == ERR_SHARING_VIOLATION ? */
rc = 0; /* do not change lock type to unlock
since range in use */
rc = 0;
if (lockType & LOCKING_ANDX_SHARED_LOCK) {
pfLock->fl_type = F_WRLCK;
} else {
rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length,
pfLock->fl_start, 0, 1,
lockType | LOCKING_ANDX_SHARED_LOCK,
0 /* wait flag */ );
if (rc == 0) {
rc = CIFSSMBLock(xid, pTcon, netfid, netpid,
length, pfLock->fl_start, 1, 0,
lockType |
LOCKING_ANDX_SHARED_LOCK,
0 /* wait flag */ );
pfLock->fl_type = F_RDLCK;
if (rc != 0)
cERROR(1, ("Error unlocking "
"previously locked range %d "
"during test of lock", rc));
} else
pfLock->fl_type = F_WRLCK;
rc = 0;
}
}
FreeXid(xid);
......
......@@ -670,14 +670,15 @@ cifs_get_sb(struct file_system_type *fs_type,
#endif
}
static ssize_t cifs_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
static ssize_t cifs_sync_read(struct file *filp, char __user *buf,
size_t len, loff_t *ppos)
{
int retval, read, posix_locking = 0;
struct file_lock pfLock;
struct cifsInodeInfo *cifsInode;
struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *tcon;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18)
cifs_sb = CIFS_SB(filp->f_path.dentry->d_sb);
tcon = cifs_sb->tcon;
if ((tcon->ses->capabilities & CAP_UNIX) &&
......@@ -697,7 +698,31 @@ static ssize_t cifs_sync_read(struct file *filp, char __user *buf, size_t len, l
if (cifsInode == NULL)
return -ENOENT;
if (!CIFS_I(filp->f_path.dentry->d_inode)->clientCanCacheRead && !posix_locking) {
if (!CIFS_I(filp->f_path.dentry->d_inode)->clientCanCacheRead
&& !posix_locking) {
#else
cifs_sb = CIFS_SB(filp->f_dentry->d_sb);
tcon = cifs_sb->tcon;
if ((tcon->ses->capabilities & CAP_UNIX) &&
(CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
posix_locking = 1;
retval = cifs_revalidate(filp->f_dentry);
if (retval < 0)
return (ssize_t)retval;
memset(&pfLock, 0, sizeof(pfLock));
pfLock.fl_type = F_RDLCK;
pfLock.fl_start = *ppos;
pfLock.fl_end = *ppos+len;
cifsInode = CIFS_I(filp->f_dentry->d_inode);
if (cifsInode == NULL)
return -ENOENT;
if (!CIFS_I(filp->f_dentry->d_inode)->clientCanCacheRead
&& !posix_locking) {
#endif
retval = cifs_lock(filp, F_GETLK, &pfLock);
if (retval < 0)
return (ssize_t)retval;
......@@ -940,7 +965,7 @@ struct file_operations cifs_file_nobrl_ops = {
const
#endif
struct file_operations cifs_file_direct_nobrl_ops = {
/* no mmap, no aio, no readv -
/* no aio, no readv -
BB reevaluate whether they can be done with directio, no cache */
.read = cifs_user_read,
.write = cifs_user_write,
......@@ -948,6 +973,7 @@ struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
.sendfile = generic_file_sendfile, /* BB removeme BB */
#else
......
......@@ -687,7 +687,8 @@ cifs_get_sb(struct file_system_type *fs_type,
#endif
}
static ssize_t cifs_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
static ssize_t cifs_sync_read(struct file *filp, char __user *buf,
size_t len, loff_t *ppos)
{
int retval, read, posix_locking = 0;
struct file_lock pfLock;
......@@ -714,7 +715,8 @@ static ssize_t cifs_sync_read(struct file *filp, char __user *buf, size_t len, l
if (cifsInode == NULL)
return -ENOENT;
if (!CIFS_I(filp->f_path.dentry->d_inode)->clientCanCacheRead && !posix_locking) {
if (!CIFS_I(filp->f_path.dentry->d_inode)->clientCanCacheRead
&& !posix_locking) {
#else
cifs_sb = CIFS_SB(filp->f_dentry->d_sb);
tcon = cifs_sb->tcon;
......@@ -735,7 +737,8 @@ static ssize_t cifs_sync_read(struct file *filp, char __user *buf, size_t len, l
if (cifsInode == NULL)
return -ENOENT;
if (!CIFS_I(filp->f_dentry->d_inode)->clientCanCacheRead && !posix_locking) {
if (!CIFS_I(filp->f_dentry->d_inode)->clientCanCacheRead
&& !posix_locking) {
#endif
retval = cifs_lock(filp, F_GETLK, &pfLock);
if (retval < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment