#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#include <linux/lustre_compat25.h>
#endif
-
#include "llite_internal.h"
-static int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode,
- struct file *file)
+int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode,
+ struct file *file)
{
struct ll_file_data *fd = file->private_data;
struct ptlrpc_request *req = NULL;
struct obd_client_handle *och = &fd->fd_mds_och;
struct obdo obdo;
- int rc, valid;
+ int rc;
ENTRY;
/* clear group lock, if present */
- if (fd->fd_flags & LL_FILE_CW_LOCKED) {
+ if (fd->fd_flags & LL_FILE_GROUP_LOCKED) {
struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
- fd->fd_flags &= ~(LL_FILE_CW_LOCKED|LL_FILE_IGNORE_LOCK);
- rc = ll_extent_unlock(fd, inode, lsm, LCK_CW, &fd->fd_cwlockh);
+ fd->fd_flags &= ~(LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK);
+ rc = ll_extent_unlock(fd, inode, lsm, LCK_GROUP,
+ &fd->fd_cwlockh);
}
- valid = OBD_MD_FLID;
-
- memset(&obdo, 0, sizeof(obdo));
obdo.o_id = inode->i_ino;
- obdo.o_mode = inode->i_mode;
- obdo.o_size = inode->i_size;
- obdo.o_blocks = inode->i_blocks;
+ obdo.o_valid = OBD_MD_FLID;
+ obdo_from_inode(&obdo, inode, OBD_MD_FLTYPE | OBD_MD_FLMODE |
+ OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
+ OBD_MD_FLATIME | OBD_MD_FLMTIME |
+ OBD_MD_FLCTIME);
if (0 /* ll_is_inode_dirty(inode) */) {
obdo.o_flags = MDS_BFLAG_UNCOMMITTED_WRITES;
- valid |= OBD_MD_FLFLAGS;
+ obdo.o_valid |= OBD_MD_FLFLAGS;
}
- obdo.o_valid = valid;
obdo.o_mds = ll_i2info(inode)->lli_mds;
rc = md_close(mdc_exp, &obdo, och, &req);
+
if (rc == EAGAIN) {
/* We are the last writer, so the MDS has instructed us to get
* the file size and any write cookies, then close again. */
inode->i_ino, rc);
}
- mdc_clear_open_replay_data(och);
+ mdc_clear_open_replay_data(mdc_exp, och);
ptlrpc_req_finished(req);
och->och_fh.cookie = DEAD_HANDLE_MAGIC;
file->private_data = NULL;
if (rc == 0) {
if (itp->d.lustre.it_lock_mode)
memcpy(&itp->d.lustre.it_lock_handle,
- &lockh, sizeof(lockh));
+ &lockh, sizeof(lockh));
} else if (rc < 0) {
CERROR("lock enqueue: err: %d\n", rc);
}
+
RETURN(rc);
}
-static int ll_local_open(struct file *file, struct lookup_intent *it)
+int ll_local_open(struct file *file, struct lookup_intent *it)
{
struct ptlrpc_request *req = it->d.lustre.it_data;
struct ll_inode_info *lli = ll_i2info(file->f_dentry->d_inode);
+ struct obd_export *mdc_exp = ll_i2mdcexp(file->f_dentry->d_inode);
struct ll_file_data *fd;
struct mds_body *body;
ENTRY;
lli->lli_io_epoch = body->io_epoch;
- mdc_set_open_replay_data(&fd->fd_mds_och, it->d.lustre.it_data);
+ mdc_set_open_replay_data(mdc_exp, &fd->fd_mds_och, it->d.lustre.it_data);
RETURN(0);
}
int ll_file_open(struct inode *inode, struct file *file)
{
struct ll_inode_info *lli = ll_i2info(inode);
- struct lookup_intent *it;
+ struct lookup_intent *it, oit = { .it_op = IT_OPEN,
+ .it_flags = file->f_flags };
struct lov_stripe_md *lsm;
struct ptlrpc_request *req;
int rc = 0;
it = file->f_it;
- if (!it->d.lustre.it_disposition) {
- struct lookup_intent oit = { .it_op = IT_OPEN,
- .it_flags = file->f_flags };
+ if (!it || !it->d.lustre.it_disposition) {
it = &oit;
rc = ll_intent_file_open(file, NULL, 0, it);
if (rc)
if (rc)
RETURN(rc);
- oa->o_valid &= (OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
+ oa->o_valid &= (OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
OBD_MD_FLCTIME | OBD_MD_FLSIZE);
RETURN(0);
}
tmpex.l_extent.start, lock->l_policy_data.l_extent.end,
start, i, end);
- ll_pgcache_lock(inode->i_mapping);
- if (list_empty(&inode->i_mapping->dirty_pages) &&
- list_empty(&inode->i_mapping->clean_pages) &&
- list_empty(&inode->i_mapping->locked_pages)) {
+ if (!mapping_has_pages(inode->i_mapping)) {
CDEBUG(D_INODE|D_PAGE, "nothing left\n");
- ll_pgcache_unlock(inode->i_mapping);
break;
}
- ll_pgcache_unlock(inode->i_mapping);
conditional_schedule();
lock_page(page);
/* page->mapping to check with racing against teardown */
- if (page->mapping && PageDirty(page) && !discard) {
- ClearPageDirty(page);
- LL_CDEBUG_PAGE(D_PAGE, page, "found dirty\n");
- ll_pgcache_lock(inode->i_mapping);
- list_del(&page->list);
- list_add(&page->list, &inode->i_mapping->locked_pages);
- ll_pgcache_unlock(inode->i_mapping);
-
+ if (!discard && clear_page_dirty_for_io(page)) {
rc = ll_call_writepage(inode, page);
if (rc != 0)
CERROR("writepage of page %p failed: %d\n",
down(&inode->i_sem);
kms = ldlm_extent_shift_kms(lock,
lsm->lsm_oinfo[stripe].loi_kms);
+
if (lsm->lsm_oinfo[stripe].loi_kms != kms)
LDLM_DEBUG(lock, "updating kms from "LPU64" to "LPU64,
lsm->lsm_oinfo[stripe].loi_kms, kms);
}
__u64 lov_merge_size(struct lov_stripe_md *lsm, int kms);
+__u64 lov_merge_blocks(struct lov_stripe_md *lsm);
__u64 lov_merge_mtime(struct lov_stripe_md *lsm, __u64 current_time);
/* NB: lov_merge_size will prefer locally cached writes if they extend the
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_sb_info *sbi = ll_i2sbi(inode);
ldlm_policy_data_t policy = { .l_extent = { 0, OBD_OBJECT_EOF } };
- struct lustre_handle lockh;
+ struct lustre_handle lockh = { 0 };
int rc, flags = LDLM_FL_HAS_INTENT;
ENTRY;
}
lvb->lvb_size = lov_merge_size(lli->lli_smd, 0);
+ inode->i_blocks = lov_merge_blocks(lli->lli_smd);
//inode->i_mtime = lov_merge_mtime(lli->lli_smd, inode->i_mtime);
- CDEBUG(D_DLMTRACE, "glimpse: size: "LPU64"\n", lvb->lvb_size);
+ CDEBUG(D_DLMTRACE, "glimpse: size: "LPU64", blocks: "LPU64"\n",
+ lvb->lvb_size, lvb->lvb_blocks);
obd_cancel(sbi->ll_osc_exp, lli->lli_smd, LCK_PR, &lockh);
struct lov_stripe_md *lsm = lli->lli_smd;
struct lustre_handle lockh = { 0 };
ldlm_policy_data_t policy;
- ldlm_error_t err;
+ int rc;
ssize_t retval;
__u64 kms;
ENTRY;
policy.l_extent.start = *ppos;
policy.l_extent.end = *ppos + count - 1;
- err = ll_extent_lock(fd, inode, lsm, LCK_PR, &policy, &lockh,
- (filp->f_flags & O_NONBLOCK)?LDLM_FL_BLOCK_NOWAIT:
- 0);
- if (err != ELDLM_OK)
- RETURN(err);
+ rc = ll_extent_lock(fd, inode, lsm, LCK_PR, &policy, &lockh,
+ (filp->f_flags & O_NONBLOCK) ?
+ LDLM_FL_BLOCK_NOWAIT: 0);
+ if (rc != 0)
+ RETURN(rc);
kms = lov_merge_size(lsm, 1);
- if (policy.l_extent.end > kms) {
+ if (*ppos + count - 1 > kms) {
/* A glimpse is necessary to determine whether we return a short
* read or some zeroes at the end of the buffer */
struct ost_lvb lvb;
struct lustre_handle lockh = { 0 };
ldlm_policy_data_t policy;
loff_t maxbytes = ll_file_maxbytes(inode);
- ldlm_error_t err;
ssize_t retval;
- int nonblock = 0;
+ int nonblock = 0, rc;
ENTRY;
if (file->f_flags & O_NONBLOCK)
nonblock = LDLM_FL_BLOCK_NOWAIT;
policy.l_extent.end = *ppos + count - 1;
}
- err = ll_extent_lock(fd, inode, lsm, LCK_PW, &policy, &lockh, nonblock);
- if (err != ELDLM_OK)
- RETURN(err);
+ rc = ll_extent_lock(fd, inode, lsm, LCK_PW, &policy, &lockh, nonblock);
+ if (rc != 0)
+ RETURN(rc);
/* this is ok, g_f_w will overwrite this under i_sem if it races
* with a local truncate, it just makes our maxbyte checking easier */
if (rc < 0)
GOTO(out, rc);
- rc = mdc_req2lustre_md(req, 1, exp, NULL, &md);
+ rc = mdc_req2lustre_md(ll_i2mdcexp(inode), req, 1, exp, &md);
if (rc)
GOTO(out, rc);
ll_update_inode(f->f_dentry->d_inode, &md);
{
int flags = MDS_OPEN_HAS_OBJS | FMODE_WRITE;
struct lov_user_md *lump;
- int lum_size = sizeof(struct lov_user_md) +
+ int lum_size = sizeof(struct lov_user_md) +
sizeof(struct lov_user_ost_data);
int rc;
ENTRY;
if (lump == NULL) {
RETURN(-ENOMEM);
}
- rc = copy_from_user(lump, (struct lov_user_md *)arg,
- lum_size);
+ rc = copy_from_user(lump, (struct lov_user_md *)arg, lum_size);
if (rc) {
OBD_FREE(lump, lum_size);
RETURN(-EFAULT);
(void *)arg);
}
-static int ll_get_cwlock(struct inode *inode, struct file *file,
+static int ll_get_grouplock(struct inode *inode, struct file *file,
unsigned long arg)
{
struct ll_file_data *fd = file->private_data;
struct lustre_handle lockh = { 0 };
struct ll_inode_info *lli = ll_i2info(inode);
struct lov_stripe_md *lsm = lli->lli_smd;
- ldlm_error_t err;
- int flags = 0;
+ int flags = 0, rc;
ENTRY;
- if (fd->fd_flags & LL_FILE_CW_LOCKED) {
+ if (fd->fd_flags & LL_FILE_GROUP_LOCKED) {
RETURN(-EINVAL);
}
if (file->f_flags & O_NONBLOCK)
flags = LDLM_FL_BLOCK_NOWAIT;
- err = ll_extent_lock(fd, inode, lsm, LCK_CW, &policy, &lockh, flags);
- if (err)
- RETURN(err);
+ rc = ll_extent_lock(fd, inode, lsm, LCK_GROUP, &policy, &lockh, flags);
+ if (rc != 0)
+ RETURN(rc);
- fd->fd_flags |= LL_FILE_CW_LOCKED|LL_FILE_IGNORE_LOCK;
+ fd->fd_flags |= LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK;
fd->fd_gid = arg;
memcpy(&fd->fd_cwlockh, &lockh, sizeof(lockh));
RETURN(0);
}
-static int ll_put_cwlock(struct inode *inode, struct file *file,
+static int ll_put_grouplock(struct inode *inode, struct file *file,
unsigned long arg)
{
struct ll_file_data *fd = file->private_data;
struct ll_inode_info *lli = ll_i2info(inode);
struct lov_stripe_md *lsm = lli->lli_smd;
- ldlm_error_t err;
+ int rc;
ENTRY;
- if (!(fd->fd_flags & LL_FILE_CW_LOCKED)) {
+ if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED)) {
/* Ugh, it's already unlocked. */
RETURN(-EINVAL);
}
if (fd->fd_gid != arg) /* Ugh? Unlocking with different gid? */
RETURN(-EINVAL);
-
- fd->fd_flags &= ~(LL_FILE_CW_LOCKED|LL_FILE_IGNORE_LOCK);
- err = ll_extent_unlock(fd, inode, lsm, LCK_CW, &fd->fd_cwlockh);
- if (err)
- RETURN(err);
+ fd->fd_flags &= ~(LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK);
+
+ rc = ll_extent_unlock(fd, inode, lsm, LCK_GROUP, &fd->fd_cwlockh);
+ if (rc)
+ RETURN(rc);
fd->fd_gid = 0;
memset(&fd->fd_cwlockh, 0, sizeof(fd->fd_cwlockh));
RETURN(0);
-}
+}
int ll_file_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg)
case LL_IOC_LOV_SETSTRIPE:
RETURN(ll_lov_setstripe(inode, file, arg));
case LL_IOC_LOV_SETEA:
- RETURN( ll_lov_setea(inode, file, arg) );
+ RETURN(ll_lov_setea(inode, file, arg));
case LL_IOC_LOV_GETSTRIPE:
RETURN(ll_lov_getstripe(inode, arg));
case LL_IOC_RECREATE_OBJ:
case EXT3_IOC_GETFLAGS:
case EXT3_IOC_SETFLAGS:
RETURN( ll_iocontrol(inode, file, cmd, arg) );
- case LL_IOC_CW_LOCK:
- RETURN(ll_get_cwlock(inode, file, arg));
- case LL_IOC_CW_UNLOCK:
- RETURN(ll_put_cwlock(inode, file, arg));
+ case LL_IOC_GROUP_LOCK:
+ RETURN(ll_get_grouplock(inode, file, arg));
+ case LL_IOC_GROUP_UNLOCK:
+ RETURN(ll_put_grouplock(inode, file, arg));
/* We need to special case any other ioctls we want to handle,
* to send them to the MDS/OST as appropriate and to properly
* network encode the arg field.
lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_LLSEEK);
if (origin == 2) { /* SEEK_END */
- ldlm_error_t err;
- int nonblock = 0;
+ int nonblock = 0, rc;
ldlm_policy_data_t policy = { .l_extent = {0, OBD_OBJECT_EOF }};
if (file->f_flags & O_NONBLOCK)
nonblock = LDLM_FL_BLOCK_NOWAIT;
- err = ll_extent_lock(fd, inode, lsm, LCK_PR, &policy, &lockh,
+ rc = ll_extent_lock(fd, inode, lsm, LCK_PR, &policy, &lockh,
nonblock);
- if (err != ELDLM_OK)
- RETURN(err);
+ if (rc != 0)
+ RETURN(rc);
offset += inode->i_size;
} else if (origin == 1) { /* SEEK_CUR */
#endif
struct file_operations ll_file_operations = {
- read: ll_file_read,
- write: ll_file_write,
- ioctl: ll_file_ioctl,
- open: ll_file_open,
- release: ll_file_release,
- mmap: generic_file_mmap,
- llseek: ll_file_seek,
- fsync: ll_fsync,
- //lock: ll_file_flock
+ .read = ll_file_read,
+ .write = ll_file_write,
+ .ioctl = ll_file_ioctl,
+ .open = ll_file_open,
+ .release = ll_file_release,
+ .mmap = generic_file_mmap,
+ .llseek = ll_file_seek,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+ .sendfile = generic_file_sendfile,
+#endif
+ .fsync = ll_fsync,
+ //.lock ll_file_flock
};
struct inode_operations ll_file_inode_operations = {
- setattr_raw: ll_setattr_raw,
- setattr: ll_setattr,
- truncate: ll_truncate,
+ .setattr_raw = ll_setattr_raw,
+ .setattr = ll_setattr,
+ .truncate = ll_truncate,
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
- getattr_it: ll_getattr,
+ .getattr_it = ll_getattr,
#else
- revalidate_it: ll_inode_revalidate_it,
+ .revalidate_it = ll_inode_revalidate_it,
#endif
};
-struct inode_operations ll_special_inode_operations = {
- setattr_raw: ll_setattr_raw,
- setattr: ll_setattr,
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
- getattr_it: ll_getattr,
-#else
- revalidate_it: ll_inode_revalidate_it,
-#endif
-};