* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*
if (lock->cll_descr.cld_start == 0 &&
lock->cll_descr.cld_end == CL_PAGE_EOF) {
cl_isize_write_nolock(inode, attr->cat_kms);
- CDEBUG(D_INODE, DFID" updating i_size "LPU64"\n",
+ CDEBUG(D_INODE|D_VFSTRACE,
+ DFID" updating i_size "LPU64"\n",
PFID(lu_object_fid(&obj->co_lu)),
(__u64)cl_isize_read(inode));
}
cl_inode_atime(inode) = attr->cat_atime;
cl_inode_ctime(inode) = attr->cat_ctime;
} else {
- CL_LOCK_DEBUG(D_INFO, env, lock, "attr_get: %i\n", rc);
+ CL_LOCK_DEBUG(D_INFO, env, lock, "attr_get: %d\n", rc);
}
cl_object_attr_unlock(obj);
cl_isize_unlock(inode, 0);
CLOBINVRNT(env, obj, ccc_object_invariant(obj));
ENTRY;
- CDEBUG(D_VFSTRACE, "lock: %i [%lu, %lu]\n", mode, start, end);
+ CDEBUG(D_VFSTRACE, "lock: %d [%lu, %lu]\n", mode, start, end);
memset(&cio->cui_link, 0, sizeof cio->cui_link);
cl_isize_write_nolock(inode, kms);
else
cl_isize_write(inode, kms);
+ CDEBUG(D_VFSTRACE,
+ DFID" updating i_size "LPU64"\n",
+ PFID(lu_object_fid(&obj->co_lu)),
+ (__u64)cl_isize_read(inode));
+
}
}
}
}
obdo_from_inode(oa, inode, &cl_i2info(inode)->lli_fid,
valid_flags & flags);
+#ifdef __KERNEL__
+ /* Bug11742 - set the OBD_FL_MMAP flag for memory mapped files */
+ if (cfs_atomic_read(&(cl_inode2ccc(inode)->cob_mmap_cnt)) != 0) {
+ if (!(oa->o_valid & OBD_MD_FLFLAGS)) {
+ oa->o_valid |= OBD_MD_FLFLAGS;
+ oa->o_flags = OBD_FL_MMAP;
+ } else {
+ oa->o_flags |= OBD_FL_MMAP;
+ }
+ }
+#endif
}
const struct cl_req_operations ccc_req_ops = {
if (IS_ERR(env))
RETURN(PTR_ERR(env));
- io = &ccc_env_info(env)->cti_io;
+ io = ccc_env_thread_io(env);
io->ci_obj = cl_i2info(inode)->lli_clob;
io->u.ci_setattr.sa_attr.lvb_atime = LTIME_S(attr->ia_atime);
struct cl_object *clob;
struct lu_site *site;
struct lu_fid *fid;
- const struct cl_object_conf conf = {
+ struct cl_object_conf conf = {
.coc_inode = inode,
.u = {
.coc_md = md
int result = 0;
int refcheck;
- /* LASSERT(inode->i_state & I_NEW); */
LASSERT(md->body->valid & OBD_MD_FLID);
if (!S_ISREG(cl_inode_mode(inode)))
LASSERT(fid_is_sane(fid));
if (lli->lli_clob == NULL) {
+ /* clob is slave of inode, empty lli_clob means for new inode,
+ * there is no clob in cache with the given fid, so it is
+ * unnecessary to perform lookup-alloc-lookup-insert, just
+ * alloc and insert directly. */
+#ifdef __KERNEL__
+ LASSERT(inode->i_state & I_NEW);
+#endif
+ conf.coc_lu.loc_flags = LOC_F_NEW;
clob = cl_object_find(env, lu2cl_dev(site->ls_top_dev),
fid, &conf);
if (!IS_ERR(clob)) {
return result;
}
+/**
+ * Wait for others drop their references of the object at first, then we drop
+ * the last one, which will lead to the object be destroyed immediately.
+ * Must be called after cl_object_kill() against this object.
+ *
+ * The reason we want to do this is: destroying top object will wait for sub
+ * objects being destroyed first, so we can't let bottom layer (e.g. from ASTs)
+ * to initiate top object destroying which may deadlock. See bz22520.
+ */
+static void cl_object_put_last(struct lu_env *env, struct cl_object *obj)
+{
+ struct lu_object_header *header = obj->co_lu.lo_header;
+ cfs_waitlink_t waiter;
+
+ if (unlikely(cfs_atomic_read(&header->loh_ref) != 1)) {
+ struct lu_site *site = obj->co_lu.lo_dev->ld_site;
+ struct lu_site_bkt_data *bkt;
+
+ bkt = lu_site_bkt_from_fid(site, &header->loh_fid);
+
+ cfs_waitlink_init(&waiter);
+ cfs_waitq_add(&bkt->lsb_marche_funebre, &waiter);
+
+ while (1) {
+ cfs_set_current_state(CFS_TASK_UNINT);
+ if (cfs_atomic_read(&header->loh_ref) == 1)
+ break;
+ cfs_waitq_wait(&waiter, CFS_TASK_UNINT);
+ }
+
+ cfs_set_current_state(CFS_TASK_RUNNING);
+ cfs_waitq_del(&bkt->lsb_marche_funebre, &waiter);
+ }
+
+ cl_object_put(env, obj);
+}
+
void cl_inode_fini(struct inode *inode)
{
struct lu_env *env;
*/
cl_object_kill(env, clob);
lu_object_ref_del(&clob->co_lu, "inode", inode);
- cl_object_put(env, clob);
+ cl_object_put_last(env, clob);
lli->lli_clob = NULL;
if (emergency) {
cl_env_unplant(ccc_inode_fini_env, &refcheck);
/**
* build inode number from passed @fid */
-ino_t cl_fid_build_ino(const struct lu_fid *fid)
+__u64 cl_fid_build_ino(const struct lu_fid *fid, int api32)
{
- ino_t ino;
- ENTRY;
-
- if (fid_is_igif(fid)) {
- ino = lu_igif_ino(fid);
- RETURN(ino);
- }
-
- /* Very stupid and having many downsides inode allocation algorithm
- * based on fid. */
- ino = fid_flatten(fid) & 0xFFFFFFFF;
-
- if (unlikely(ino == 0))
- /* the first result ino is 0xFFC001, so this is rarely used */
- ino = 0xffbcde;
- ino = ino | 0x80000000;
- RETURN(ino);
+ if (BITS_PER_LONG == 32 || api32)
+ RETURN(fid_flatten32(fid));
+ else
+ RETURN(fid_flatten(fid));
}
/**