X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fllite%2Ffile.c;h=4ca1911a0d860451f62e27f33fbf61ee97d371a0;hb=71535dbbb89774eecb2f83eff80b19515e14da70;hp=acb227240ddef1859db3ce838992f15fd019f2f3;hpb=cec72a356891eaa729314a7bc89c4b2aaef0a31b;p=fs%2Flustre-release.git diff --git a/lustre/llite/file.c b/lustre/llite/file.c index acb2272..4ca1911 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -331,7 +331,7 @@ int ll_file_release(struct inode *inode, struct file *file) rc = ll_md_close(sbi->ll_md_exp, inode, file); - if (OBD_FAIL_TIMEOUT_MS(OBD_FAIL_PTLRPC_DUMP_LOG, obd_fail_val)) + if (CFS_FAIL_TIMEOUT_MS(OBD_FAIL_PTLRPC_DUMP_LOG, cfs_fail_val)) libcfs_debug_dumplog(); RETURN(rc); @@ -346,6 +346,7 @@ static int ll_intent_file_open(struct file *file, void *lmm, const int len = file->f_dentry->d_name.len; struct md_op_data *op_data; struct ptlrpc_request *req; + __u32 opc = LUSTRE_OPC_ANY; int rc; ENTRY; @@ -361,12 +362,15 @@ static int ll_intent_file_open(struct file *file, void *lmm, * makes a good candidate for using OPEN lock */ /* If lmmsize & lmm are not 0, we are just setting stripe info * parameters. No need for the open lock */ - if (!lmm && !lmmsize) + if (lmm == NULL && lmmsize == 0) { itp->it_flags |= MDS_OPEN_LOCK; + if (itp->it_flags & FMODE_WRITE) + opc = LUSTRE_OPC_CREATE; + } op_data = ll_prep_md_op_data(NULL, parent->d_inode, file->f_dentry->d_inode, name, len, - O_RDWR, LUSTRE_OPC_ANY, NULL); + O_RDWR, opc, NULL); if (IS_ERR(op_data)) RETURN(PTR_ERR(op_data)); @@ -502,12 +506,8 @@ int ll_file_open(struct inode *inode, struct file *file) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), flags %o\n", inode->i_ino, inode->i_generation, inode, file->f_flags); -#ifdef HAVE_VFS_INTENT_PATCHES - it = file->f_it; -#else it = file->private_data; /* XXX: compat macro */ file->private_data = NULL; /* prevent ll_local_open assertion */ -#endif fd = ll_file_data_get(); if (fd == NULL) @@ -543,7 +543,7 @@ int ll_file_open(struct inode *inode, struct file *file) * dentry_open after call to open_namei that checks permissions. * Only nfsd_open call dentry_open directly without checking * permissions and because of that this code below is safe. */ - if (oit.it_flags & FMODE_WRITE) + if (oit.it_flags & (FMODE_WRITE | FMODE_READ)) oit.it_flags |= MDS_OPEN_OWNEROVERRIDE; /* We do not want O_EXCL here, presumably we opened the file @@ -812,7 +812,6 @@ void ll_io_init(struct cl_io *io, const struct file *file, int write) { struct inode *inode = file->f_dentry->d_inode; - memset(io, 0, sizeof *io); io->u.ci_rw.crw_nonblock = file->f_flags & O_NONBLOCK; if (write) io->u.ci_wr.wr_append = !!(file->f_flags & O_APPEND); @@ -835,7 +834,7 @@ static ssize_t ll_file_io_generic(const struct lu_env *env, ssize_t result; ENTRY; - io = &ccc_env_info(env)->cti_io; + io = ccc_env_thread_io(env); ll_io_init(io, file, iot == CIT_WRITE); if (cl_io_rw_init(env, io, iot, *ppos, count) == 0) { @@ -1465,12 +1464,13 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file, static int ll_lov_getstripe(struct inode *inode, unsigned long arg) { struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd; + int rc = -ENODATA; + ENTRY; - if (!lsm) - RETURN(-ENODATA); - - return obd_iocontrol(LL_IOC_LOV_GETSTRIPE, ll_i2dtexp(inode), 0, lsm, - (void *)arg); + if (lsm != NULL) + rc = obd_iocontrol(LL_IOC_LOV_GETSTRIPE, ll_i2dtexp(inode), 0, + lsm, (void *)arg); + RETURN(rc); } int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) @@ -1956,27 +1956,32 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data) ptlrpc_req_finished(req); if (data && lsm) { - struct obdo *oa; + struct obd_info *oinfo; - OBDO_ALLOC(oa); - if (!oa) + OBD_ALLOC_PTR(oinfo); + if (!oinfo) RETURN(rc ? rc : -ENOMEM); - - oa->o_id = lsm->lsm_object_id; - oa->o_seq = lsm->lsm_object_seq; - oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP; - obdo_from_inode(oa, inode, &ll_i2info(inode)->lli_fid, + OBDO_ALLOC(oinfo->oi_oa); + if (!oinfo->oi_oa) { + OBD_FREE_PTR(oinfo); + RETURN(rc ? rc : -ENOMEM); + } + oinfo->oi_oa->o_id = lsm->lsm_object_id; + oinfo->oi_oa->o_seq = lsm->lsm_object_seq; + oinfo->oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP; + obdo_from_inode(oinfo->oi_oa, inode, &ll_i2info(inode)->lli_fid, OBD_MD_FLTYPE | OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLGROUP); - - oc = ll_osscapa_get(inode, CAPA_OPC_OSS_WRITE); - err = obd_sync(ll_i2sbi(inode)->ll_dt_exp, oa, lsm, - 0, OBD_OBJECT_EOF, oc); - capa_put(oc); + oinfo->oi_md = lsm; + oinfo->oi_capa = ll_osscapa_get(inode, CAPA_OPC_OSS_WRITE); + err = obd_sync_rqset(ll_i2sbi(inode)->ll_dt_exp, oinfo, 0, + OBD_OBJECT_EOF); + capa_put(oinfo->oi_capa); if (!rc) rc = err; - OBDO_FREE(oa); + OBDO_FREE(oinfo->oi_oa); + OBD_FREE_PTR(oinfo); lli->lli_write_rc = err < 0 ? : 0; } @@ -1992,7 +1997,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) .ei_cbdata = file_lock }; struct md_op_data *op_data; struct lustre_handle lockh = {0}; - ldlm_policy_data_t flock; + ldlm_policy_data_t flock = {{0}}; int flags = 0; int rc; ENTRY; @@ -2004,13 +2009,28 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) if (file_lock->fl_flags & FL_FLOCK) { LASSERT((cmd == F_SETLKW) || (cmd == F_SETLK)); - /* set missing params for flock() calls */ - file_lock->fl_end = OFFSET_MAX; - file_lock->fl_pid = current->tgid; + /* flocks are whole-file locks */ + flock.l_flock.end = OFFSET_MAX; + /* For flocks owner is determined by the local file desctiptor*/ + flock.l_flock.owner = (unsigned long)file_lock->fl_file; + } else if (file_lock->fl_flags & FL_POSIX) { + flock.l_flock.owner = (unsigned long)file_lock->fl_owner; + flock.l_flock.start = file_lock->fl_start; + flock.l_flock.end = file_lock->fl_end; + } else { + RETURN(-EINVAL); } flock.l_flock.pid = file_lock->fl_pid; - flock.l_flock.start = file_lock->fl_start; - flock.l_flock.end = file_lock->fl_end; + + /* Somewhat ugly workaround for svc lockd. + * lockd installs custom fl_lmops->fl_compare_owner that checks + * for the fl_owner to be the same (which it always is on local node + * I guess between lockd processes) and then compares pid. + * As such we assign pid to the owner field to make it all work, + * conflict with normal locks is unlikely since pid space and + * pointer space for current->files are not intersecting */ + if (file_lock->fl_lmops && file_lock->fl_lmops->fl_compare_owner) + flock.l_flock.owner = (unsigned long)file_lock->fl_pid; switch (file_lock->fl_type) { case F_RDLCK: @@ -2188,6 +2208,9 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, struct lookup_intent oit = { .it_op = IT_GETATTR }; struct md_op_data *op_data; + if (ibits == MDS_INODELOCK_LOOKUP) + oit.it_op = IT_LOOKUP; + /* Call getattr by fid, so do not provide name at all. */ op_data = ll_prep_md_op_data(NULL, dentry->d_parent->d_inode, dentry->d_inode, NULL, 0, 0, @@ -2264,14 +2287,14 @@ out: return rc; } -int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) +int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, + __u64 ibits) { struct inode *inode = dentry->d_inode; int rc; ENTRY; - rc = __ll_inode_revalidate_it(dentry, it, MDS_INODELOCK_UPDATE | - MDS_INODELOCK_LOOKUP); + rc = __ll_inode_revalidate_it(dentry, it, ibits); /* if object not yet allocated, don't validate size */ if (rc == 0 && ll_i2info(dentry->d_inode)->lli_smd == NULL) { @@ -2294,21 +2317,22 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de, struct lookup_intent *it, struct kstat *stat) { struct inode *inode = de->d_inode; + struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_inode_info *lli = ll_i2info(inode); int res = 0; - res = ll_inode_revalidate_it(de, it); - ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETATTR, 1); + res = ll_inode_revalidate_it(de, it, MDS_INODELOCK_UPDATE | + MDS_INODELOCK_LOOKUP); + ll_stats_ops_tally(sbi, LPROC_LL_GETATTR, 1); if (res) return res; stat->dev = inode->i_sb->s_dev; - if (ll_need_32bit_api(ll_i2sbi(inode))) - stat->ino = cl_fid_build_ino32(&lli->lli_fid); + if (ll_need_32bit_api(sbi)) + stat->ino = cl_fid_build_ino(&lli->lli_fid, 1); else stat->ino = inode->i_ino; - stat->mode = inode->i_mode; stat->nlink = inode->i_nlink; stat->uid = inode->i_uid; @@ -2576,9 +2600,6 @@ struct file_operations ll_file_operations_noflock = { }; struct inode_operations ll_file_inode_operations = { -#ifdef HAVE_VFS_INTENT_PATCHES - .setattr_raw = ll_setattr_raw, -#endif .setattr = ll_setattr, .truncate = ll_truncate, .getattr = ll_getattr,