Skip to content
Snippets Groups Projects
Commit 33fb8f77 authored by Phil Schwan's avatar Phil Schwan
Browse files

- ll_file_open was not passing the correct file->f_flags to mdc_open. Fixed.

parent 61837ba0
No related branches found
No related tags found
No related merge requests found
/* /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
* linux/fs/ext2/file.c * linux/fs/ext2/file.c
* *
* This code is issued under the GNU General Public License. * This code is issued under the GNU General Public License.
...@@ -44,97 +46,102 @@ extern inline struct obdo * ll_oa_from_inode(struct inode *inode, int valid); ...@@ -44,97 +46,102 @@ extern inline struct obdo * ll_oa_from_inode(struct inode *inode, int valid);
static int ll_file_open(struct inode *inode, struct file *file) static int ll_file_open(struct inode *inode, struct file *file)
{ {
int rc; int rc;
int flags = 0; struct ptlrpc_request *req;
struct ptlrpc_request *req; struct ll_file_data *fd;
struct ll_file_data *fd; struct obdo *oa;
struct obdo *oa;
struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_sb_info *sbi = ll_i2sbi(inode);
ENTRY; ENTRY;
fd = kmem_cache_alloc(ll_file_data_slab, SLAB_KERNEL); if (file->private_data)
if (!fd) { BUG();
rc = -ENOMEM;
goto out; fd = kmem_cache_alloc(ll_file_data_slab, SLAB_KERNEL);
} if (!fd) {
rc = -ENOMEM;
goto out;
}
oa = ll_oa_from_inode(inode, (OBD_MD_FLMODE | OBD_MD_FLID)); oa = ll_oa_from_inode(inode, (OBD_MD_FLMODE | OBD_MD_FLID));
if (oa == NULL) if (oa == NULL)
BUG(); BUG();
rc = obd_open(ll_i2obdconn(inode), oa); rc = obd_open(ll_i2obdconn(inode), oa);
obdo_free(oa); obdo_free(oa);
if (rc) { if (rc) {
if (rc > 0) if (rc > 0)
rc = -rc; rc = -rc;
EXIT; EXIT;
goto out; goto out;
} }
rc = mdc_open(&sbi->ll_mds_client, inode->i_ino, S_IFREG, flags, rc = mdc_open(&sbi->ll_mds_client, inode->i_ino, S_IFREG,
&fd->fd_mdshandle, &req); file->f_flags, &fd->fd_mdshandle, &req);
ptlrpc_free_req(req); if (!fd->fd_mdshandle)
if (rc) { BUG();
if (rc > 0)
rc = -rc; ptlrpc_free_req(req);
EXIT; if (rc) {
goto out; if (rc > 0)
} rc = -rc;
file->private_data = fd; EXIT;
goto out;
EXIT; }
file->private_data = fd;
EXIT;
out: out:
if (rc && fd) { if (rc && fd)
kmem_cache_free(ll_file_data_slab, fd); kmem_cache_free(ll_file_data_slab, fd);
}
return rc; return rc;
} }
static int ll_file_release(struct inode *inode, struct file *file) static int ll_file_release(struct inode *inode, struct file *file)
{ {
int rc; int rc;
struct ptlrpc_request *req; struct ptlrpc_request *req;
struct ll_file_data *fd; struct ll_file_data *fd;
struct obdo *oa; struct obdo *oa;
struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_sb_info *sbi = ll_i2sbi(inode);
ENTRY; ENTRY;
fd = (struct ll_file_data *)file->private_data; fd = (struct ll_file_data *)file->private_data;
if (!fd) { if (!fd || !fd->fd_mdshandle) {
BUG(); BUG();
rc = -EINVAL; rc = -EINVAL;
goto out; goto out;
} }
oa = ll_oa_from_inode(inode, (OBD_MD_FLMODE | OBD_MD_FLID)); oa = ll_oa_from_inode(inode, (OBD_MD_FLMODE | OBD_MD_FLID));
if (oa == NULL) if (oa == NULL)
BUG(); BUG();
rc = obd_close(ll_i2obdconn(inode), oa); rc = obd_close(ll_i2obdconn(inode), oa);
obdo_free(oa); obdo_free(oa);
if (rc) { if (rc) {
if (rc > 0) if (rc > 0)
rc = -rc; rc = -rc;
EXIT; EXIT;
goto out; goto out;
} }
rc = mdc_close(&sbi->ll_mds_client, inode->i_ino, S_IFREG, rc = mdc_close(&sbi->ll_mds_client, inode->i_ino, S_IFREG,
fd->fd_mdshandle, &req); fd->fd_mdshandle, &req);
ptlrpc_free_req(req); ptlrpc_free_req(req);
if (rc) { if (rc) {
if (rc > 0) if (rc > 0)
rc = -rc; rc = -rc;
EXIT; EXIT;
goto out; goto out;
} }
EXIT; EXIT;
out: out:
if (!rc && fd) { if (!rc && fd) {
kmem_cache_free(ll_file_data_slab, fd); kmem_cache_free(ll_file_data_slab, fd);
file->private_data = NULL; file->private_data = NULL;
} }
return rc; return rc;
} }
...@@ -149,7 +156,7 @@ static inline void ll_remove_suid(struct inode *inode) ...@@ -149,7 +156,7 @@ static inline void ll_remove_suid(struct inode *inode)
mode &= inode->i_mode; mode &= inode->i_mode;
if (mode && !capable(CAP_FSETID)) { if (mode && !capable(CAP_FSETID)) {
inode->i_mode &= ~mode; inode->i_mode &= ~mode;
// XXX careful here - we cannot change the size // XXX careful here - we cannot change the size
} }
} }
...@@ -167,12 +174,12 @@ ll_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos) ...@@ -167,12 +174,12 @@ ll_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
retval = generic_file_write(file, buf, count, ppos); retval = generic_file_write(file, buf, count, ppos);
CDEBUG(D_INFO, "Wrote %d\n", retval); CDEBUG(D_INFO, "Wrote %d\n", retval);
/* update mtime/ctime/atime here, NOT size */ /* update mtime/ctime/atime here, NOT size */
if (retval > 0) { if (retval > 0) {
struct iattr attr; struct iattr attr;
attr.ia_valid = ATTR_MTIME | ATTR_CTIME | ATTR_ATIME; attr.ia_valid = ATTR_MTIME | ATTR_CTIME | ATTR_ATIME;
attr.ia_mtime = attr.ia_ctime = attr.ia_atime = attr.ia_mtime = attr.ia_ctime = attr.ia_atime =
CURRENT_TIME; CURRENT_TIME;
ll_setattr(file->f_dentry, &attr); ll_setattr(file->f_dentry, &attr);
} }
EXIT; EXIT;
...@@ -184,21 +191,21 @@ ll_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos) ...@@ -184,21 +191,21 @@ ll_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
call setattr */ call setattr */
int ll_fsync(struct file *file, struct dentry *dentry, int data) int ll_fsync(struct file *file, struct dentry *dentry, int data)
{ {
return 0; return 0;
} }
struct file_operations ll_file_operations = { struct file_operations ll_file_operations = {
read: generic_file_read, read: generic_file_read,
write: ll_file_write, write: ll_file_write,
open: ll_file_open, open: ll_file_open,
release: ll_file_release, release: ll_file_release,
mmap: generic_file_mmap, mmap: generic_file_mmap,
fsync: NULL fsync: NULL
}; };
struct inode_operations ll_file_inode_operations = { struct inode_operations ll_file_inode_operations = {
truncate: ll_truncate, truncate: ll_truncate,
setattr: ll_setattr setattr: ll_setattr
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment