Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
b=21551 holding ->lli_size_sem to update inode size
[fs/lustre-release.git]
/
lustre
/
lclient
/
lcommon_cl.c
diff --git
a/lustre/lclient/lcommon_cl.c
b/lustre/lclient/lcommon_cl.c
index
c06573a
..
1bb57b3
100644
(file)
--- a/
lustre/lclient/lcommon_cl.c
+++ b/
lustre/lclient/lcommon_cl.c
@@
-144,7
+144,7
@@
void *ccc_key_init(const struct lu_context *ctx,
{
struct ccc_thread_info *info;
- OBD_SLAB_ALLOC_PTR
(info, ccc_thread_kmem
);
+ OBD_SLAB_ALLOC_PTR
_GFP(info, ccc_thread_kmem, CFS_ALLOC_IO
);
if (info == NULL)
info = ERR_PTR(-ENOMEM);
return info;
@@
-162,7
+162,7
@@
void *ccc_session_key_init(const struct lu_context *ctx,
{
struct ccc_session *session;
- OBD_SLAB_ALLOC_PTR
(session, ccc_session_kmem
);
+ OBD_SLAB_ALLOC_PTR
_GFP(session, ccc_session_kmem, CFS_ALLOC_IO
);
if (session == NULL)
session = ERR_PTR(-ENOMEM);
return session;
@@
-280,7
+280,7
@@
int ccc_req_init(const struct lu_env *env, struct cl_device *dev,
struct ccc_req *vrq;
int result;
- OBD_SLAB_ALLOC_PTR
(vrq, ccc_req_kmem
);
+ OBD_SLAB_ALLOC_PTR
_GFP(vrq, ccc_req_kmem, CFS_ALLOC_IO
);
if (vrq != NULL) {
cl_req_slice_add(req, &vrq->crq_cl, dev, &ccc_req_ops);
result = 0;
@@
-300,7
+300,7
@@
static struct lu_env *ccc_inode_fini_env = NULL;
* A mutex serializing calls to slp_inode_fini() under extreme memory
* pressure, when environments cannot be allocated.
*/
-static DEFINE_MUTEX(ccc_inode_fini_guard);
+static
CFS_
DEFINE_MUTEX(ccc_inode_fini_guard);
static int dummy_refcheck;
int ccc_global_init(struct lu_device_type *device_type)
@@
-337,7
+337,7
@@
void ccc_global_fini(struct lu_device_type *device_type)
*/
struct lu_object *ccc_object_alloc(const struct lu_env *env,
- const struct lu_object_header *
_
,
+ const struct lu_object_header *
unused
,
struct lu_device *dev,
const struct cl_object_operations *clops,
const struct lu_object_operations *luops)
@@
-345,7
+345,7
@@
struct lu_object *ccc_object_alloc(const struct lu_env *env,
struct ccc_object *vob;
struct lu_object *obj;
- OBD_SLAB_ALLOC_PTR
(vob, ccc_object_kmem
);
+ OBD_SLAB_ALLOC_PTR
_GFP(vob, ccc_object_kmem, CFS_ALLOC_IO
);
if (vob != NULL) {
struct cl_object_header *hdr;
@@
-405,7
+405,7
@@
void ccc_object_free(const struct lu_env *env, struct lu_object *obj)
int ccc_lock_init(const struct lu_env *env,
struct cl_object *obj, struct cl_lock *lock,
- const struct cl_io *
_
,
+ const struct cl_io *
unused
,
const struct cl_lock_operations *lkops)
{
struct ccc_lock *clk;
@@
-413,7
+413,7
@@
int ccc_lock_init(const struct lu_env *env,
CLOBINVRNT(env, obj, ccc_object_invariant(obj));
- OBD_SLAB_ALLOC_PTR
(clk, ccc_lock_kmem
);
+ OBD_SLAB_ALLOC_PTR
_GFP(clk, ccc_lock_kmem, CFS_ALLOC_IO
);
if (clk != NULL) {
cl_lock_slice_add(lock, &clk->clk_cl, obj, lkops);
result = 0;
@@
-465,7
+465,7
@@
int ccc_page_is_under_lock(const struct lu_env *env,
const struct cl_page_slice *slice,
struct cl_io *io)
{
- struct ccc_io *
v
io = ccc_env_io(env);
+ struct ccc_io *
c
io = ccc_env_io(env);
struct cl_lock_descr *desc = &ccc_env_info(env)->cti_descr;
struct cl_page *page = slice->cpl_page;
@@
-475,7
+475,7
@@
int ccc_page_is_under_lock(const struct lu_env *env,
if (io->ci_type == CIT_READ || io->ci_type == CIT_WRITE ||
io->ci_type == CIT_FAULT) {
- if (
v
io->cui_fd->fd_flags & LL_FILE_GROUP_LOCKED)
+ if (
c
io->cui_fd->fd_flags & LL_FILE_GROUP_LOCKED)
result = -EBUSY;
else {
desc->cld_start = page->cp_index;
@@
-503,37
+503,39
@@
void ccc_transient_page_verify(const struct cl_page *page)
{
}
-
void
ccc_transient_page_own(const struct lu_env *env,
+
int
ccc_transient_page_own(const struct lu_env *env,
const struct cl_page_slice *slice,
- struct cl_io *_)
+ struct cl_io *unused,
+ int nonblock)
{
ccc_transient_page_verify(slice->cpl_page);
+ return 0;
}
void ccc_transient_page_assume(const struct lu_env *env,
const struct cl_page_slice *slice,
- struct cl_io *
_
)
+ struct cl_io *
unused
)
{
ccc_transient_page_verify(slice->cpl_page);
}
void ccc_transient_page_unassume(const struct lu_env *env,
const struct cl_page_slice *slice,
- struct cl_io *
_
)
+ struct cl_io *
unused
)
{
ccc_transient_page_verify(slice->cpl_page);
}
void ccc_transient_page_disown(const struct lu_env *env,
const struct cl_page_slice *slice,
- struct cl_io *
_
)
+ struct cl_io *
unused
)
{
ccc_transient_page_verify(slice->cpl_page);
}
void ccc_transient_page_discard(const struct lu_env *env,
const struct cl_page_slice *slice,
- struct cl_io *
_
)
+ struct cl_io *
unused
)
{
struct cl_page *page = slice->cpl_page;
@@
-547,7
+549,7
@@
void ccc_transient_page_discard(const struct lu_env *env,
int ccc_transient_page_prep(const struct lu_env *env,
const struct cl_page_slice *slice,
- struct cl_io *
_
)
+ struct cl_io *
unused
)
{
ENTRY;
/* transient page should always be sent. */
@@
-560,17
+562,21
@@
int ccc_transient_page_prep(const struct lu_env *env,
*
*/
+void ccc_lock_delete(const struct lu_env *env,
+ const struct cl_lock_slice *slice)
+{
+ CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj));
+}
+
void ccc_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice)
{
struct ccc_lock *clk = cl2ccc_lock(slice);
-
- CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj));
OBD_SLAB_FREE_PTR(clk, ccc_lock_kmem);
}
int ccc_lock_enqueue(const struct lu_env *env,
const struct cl_lock_slice *slice,
- struct cl_io *
_
, __u32 enqflags)
+ struct cl_io *
unused
, __u32 enqflags)
{
CLOBINVRNT(env, slice->cls_obj, ccc_object_invariant(slice->cls_obj));
return 0;
@@
-595,7
+601,6
@@
int ccc_lock_wait(const struct lu_env *env, const struct cl_lock_slice *slice)
* cached lock "fits" into io.
*
* \param slice lock to be checked
- *
* \param io IO that wants a lock.
*
* \see lov_lock_fits_into().
@@
-620,12
+625,10
@@
int ccc_lock_fits_into(const struct lu_env *env,
*/
if (cio->cui_glimpse)
result = descr->cld_mode != CLM_WRITE;
+
/*
* Also, don't match incomplete write locks for read, otherwise read
* would enqueue missing sub-locks in the write mode.
- *
- * XXX this is a candidate for generic locking policy, to be moved
- * into cl_lock_lookup().
*/
else if (need->cld_mode != descr->cld_mode)
result = lock->cll_state >= CLS_ENQUEUED;
@@
-661,7
+664,7
@@
void ccc_lock_state(const struct lu_env *env,
obj = slice->cls_obj;
inode = ccc_object_inode(obj);
- attr =
&ccc_env_info(env)->cti_attr
;
+ attr =
ccc_env_thread_attr(env)
;
/* vmtruncate()->ll_truncate() first sets the i_size and then
* the kms under both a DLM lock and the
@@
-679,7
+682,7
@@
void ccc_lock_state(const struct lu_env *env,
if (rc == 0) {
if (lock->cll_descr.cld_start == 0 &&
lock->cll_descr.cld_end == CL_PAGE_EOF) {
- cl_isize_write(inode, attr->cat_kms);
+ cl_isize_write
_nolock
(inode, attr->cat_kms);
CDEBUG(D_INODE, DFID" updating i_size %llu\n",
PFID(lu_object_fid(&obj->co_lu)),
(__u64)cl_isize_read(inode));
@@
-687,8
+690,9
@@
void ccc_lock_state(const struct lu_env *env,
cl_inode_mtime(inode) = attr->cat_mtime;
cl_inode_atime(inode) = attr->cat_atime;
cl_inode_ctime(inode) = attr->cat_ctime;
- } else
- CL_LOCK_DEBUG(D_ERROR, env, lock, "attr_get: %i\n", rc);
+ } else {
+ CL_LOCK_DEBUG(D_INFO, env, lock, "attr_get: %i\n", rc);
+ }
cl_object_attr_unlock(obj);
cl_isize_unlock(inode, 0);
}
@@
-712,8
+716,8
@@
int ccc_io_one_lock_index(const struct lu_env *env, struct cl_io *io,
__u32 enqflags, enum cl_lock_mode mode,
pgoff_t start, pgoff_t end)
{
- struct ccc_io *
v
io = ccc_env_io(env);
- struct cl_lock_descr *descr = &
v
io->cui_link.cill_descr;
+ struct ccc_io *
c
io = ccc_env_io(env);
+ struct cl_lock_descr *descr = &
c
io->cui_link.cill_descr;
struct cl_object *obj = io->ci_obj;
CLOBINVRNT(env, obj, ccc_object_invariant(obj));
@@
-721,23
+725,58
@@
int ccc_io_one_lock_index(const struct lu_env *env, struct cl_io *io,
CDEBUG(D_VFSTRACE, "lock: %i [%lu, %lu]\n", mode, start, end);
- memset(&vio->cui_link, 0, sizeof vio->cui_link);
- descr->cld_mode = mode;
+ memset(&cio->cui_link, 0, sizeof cio->cui_link);
+
+ if (cio->cui_fd && (cio->cui_fd->fd_flags & LL_FILE_GROUP_LOCKED)) {
+ descr->cld_mode = CLM_GROUP;
+ descr->cld_gid = cio->cui_fd->fd_grouplock.cg_gid;
+ } else {
+ descr->cld_mode = mode;
+ }
descr->cld_obj = obj;
descr->cld_start = start;
descr->cld_end = end;
+ descr->cld_enq_flags = enqflags;
- vio->cui_link.cill_enq_flags = enqflags;
- cl_io_lock_add(env, io, &vio->cui_link);
+ cl_io_lock_add(env, io, &cio->cui_link);
RETURN(0);
}
+void ccc_io_update_iov(const struct lu_env *env,
+ struct ccc_io *cio, struct cl_io *io)
+{
+ int i;
+ size_t size = io->u.ci_rw.crw_count;
+
+ cio->cui_iov_olen = 0;
+ if (!cl_is_normalio(env, io) || size == cio->cui_tot_count)
+ return;
+
+ if (cio->cui_tot_nrsegs == 0)
+ cio->cui_tot_nrsegs = cio->cui_nrsegs;
+
+ for (i = 0; i < cio->cui_tot_nrsegs; i++) {
+ struct iovec *iv = &cio->cui_iov[i];
+
+ if (iv->iov_len < size)
+ size -= iv->iov_len;
+ else {
+ if (iv->iov_len > size) {
+ cio->cui_iov_olen = iv->iov_len;
+ iv->iov_len = size;
+ }
+ break;
+ }
+ }
+
+ cio->cui_nrsegs = i + 1;
+}
+
int ccc_io_one_lock(const struct lu_env *env, struct cl_io *io,
__u32 enqflags, enum cl_lock_mode mode,
loff_t start, loff_t end)
{
struct cl_object *obj = io->ci_obj;
-
return ccc_io_one_lock_index(env, io, enqflags, mode,
cl_index(obj, start), cl_index(obj, end));
}
@@
-748,6
+787,38
@@
void ccc_io_end(const struct lu_env *env, const struct cl_io_slice *ios)
ccc_object_invariant(ios->cis_io->ci_obj));
}
+void ccc_io_advance(const struct lu_env *env,
+ const struct cl_io_slice *ios,
+ size_t nob)
+{
+ struct ccc_io *cio = cl2ccc_io(env, ios);
+ struct cl_io *io = ios->cis_io;
+ struct cl_object *obj = ios->cis_io->ci_obj;
+
+ CLOBINVRNT(env, obj, ccc_object_invariant(obj));
+
+ if (cl_is_normalio(env, io) && io->ci_continue) {
+ /* update the iov */
+ LASSERT(cio->cui_tot_nrsegs >= cio->cui_nrsegs);
+ LASSERT(cio->cui_tot_count >= nob);
+
+ cio->cui_iov += cio->cui_nrsegs;
+ cio->cui_tot_nrsegs -= cio->cui_nrsegs;
+ cio->cui_tot_count -= nob;
+
+ if (cio->cui_iov_olen) {
+ struct iovec *iv;
+
+ cio->cui_iov--;
+ cio->cui_tot_nrsegs++;
+ iv = &cio->cui_iov[0];
+ iv->iov_base += iv->iov_len;
+ LASSERT(cio->cui_iov_olen > iv->iov_len);
+ iv->iov_len = cio->cui_iov_olen - iv->iov_len;
+ }
+ }
+}
+
static void ccc_object_size_lock(struct cl_object *obj, int vfslock)
{
struct inode *inode = ccc_object_inode(obj);
@@
-781,10
+852,12
@@
static void ccc_object_size_unlock(struct cl_object *obj, int vfslock)
* the resulting races.
*/
int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
- struct cl_io *io, loff_t pos, int vfslock)
+ struct cl_io *io, loff_t start, size_t count, int vfslock,
+ int *exceed)
{
- struct cl_attr *attr =
&ccc_env_info(env)->cti_attr
;
+ struct cl_attr *attr =
ccc_env_thread_attr(env)
;
struct inode *inode = ccc_object_inode(obj);
+ loff_t pos = start + count - 1;
loff_t kms;
int result;
@@
-818,7
+891,21
@@
int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
* of the buffer (C)
*/
ccc_object_size_unlock(obj, vfslock);
- return cl_glimpse_lock(env, io, inode, obj);
+ result = cl_glimpse_lock(env, io, inode, obj);
+ if (result == 0 && exceed != NULL) {
+ /* If objective page index exceed end-of-file
+ * page index, return directly. Do not expect
+ * kernel will check such case correctly.
+ * linux-2.6.18-128.1.1 miss to do that.
+ * --bug 17336 */
+ loff_t size = cl_isize_read(inode);
+ unsigned long cur_index = start >> CFS_PAGE_SHIFT;
+
+ if ((size == 0 && cur_index != 0) ||
+ (((size - 1) >> CFS_PAGE_SHIFT) < cur_index))
+ *exceed = 1;
+ }
+ return result;
} else {
/*
* region is within kms and, hence, within real file
@@
-845,9
+932,9
@@
int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
*/
if (cl_isize_read(inode) < kms) {
if (vfslock)
- cl_isize_write(inode, kms);
- else
cl_isize_write_nolock(inode, kms);
+ else
+ cl_isize_write(inode, kms);
}
}
}
@@
-884,7
+971,7
@@
void ccc_req_completion(const struct lu_env *env,
*
* - o_generation
*
- * -
and IO epoch (stored in o_easize)
,
+ * -
o_ioepoch
,
*
* and capability.
*/
@@
-912,7
+999,7
@@
void ccc_req_attr_set(const struct lu_env *env,
if (slice->crs_req->crq_type == CRT_WRITE) {
if (flags & OBD_MD_FLEPOCH) {
oa->o_valid |= OBD_MD_FLEPOCH;
- oa->o_
easize
= cl_i2info(inode)->lli_ioepoch;
+ oa->o_
ioepoch
= cl_i2info(inode)->lli_ioepoch;
valid_flags |= OBD_MD_FLMTIME|OBD_MD_FLCTIME|
OBD_MD_FLUID|OBD_MD_FLGID|
OBD_MD_FLFID|OBD_MD_FLGENER;
@@
-978,6
+1065,7
@@
int cl_setattr_ost(struct inode *inode, struct obd_capa *capa)
oinfo.oi_oa = oa;
oinfo.oi_md = lsm;
+ oinfo.oi_capa = capa;
/* XXX: this looks unnecessary now. */
rc = obd_setattr_rqset(cl_i2sbi(inode)->ll_dt_exp, &oinfo,
@@
-1155,14
+1243,13
@@
void cl_inode_fini(struct inode *inode)
int emergency;
if (clob != NULL) {
- struct lu_object_header *head = clob->co_lu.lo_header;
void *cookie;
cookie = cl_env_reenter();
env = cl_env_get(&refcheck);
emergency = IS_ERR(env);
if (emergency) {
- mutex_lock(&ccc_inode_fini_guard);
+
cfs_
mutex_lock(&ccc_inode_fini_guard);
LASSERT(ccc_inode_fini_env != NULL);
cl_env_implant(ccc_inode_fini_env, &refcheck);
env = ccc_inode_fini_env;
@@
-1174,13
+1261,11
@@
void cl_inode_fini(struct inode *inode)
*/
cl_object_kill(env, clob);
lu_object_ref_del(&clob->co_lu, "inode", inode);
- /* XXX temporary: this is racy */
- LASSERT(atomic_read(&head->loh_ref) == 1);
cl_object_put(env, clob);
lli->lli_clob = NULL;
if (emergency) {
cl_env_unplant(ccc_inode_fini_env, &refcheck);
- mutex_unlock(&ccc_inode_fini_guard);
+
cfs_
mutex_unlock(&ccc_inode_fini_guard);
} else
cl_env_put(env, &refcheck);
cl_env_reexit(cookie);
@@
-1208,3
+1293,43
@@
__u16 ll_dirent_type_get(struct lu_dirent *ent)
}
return type;
}
+
+/**
+ * build inode number from passed @fid */
+ino_t cl_fid_build_ino(const struct lu_fid *fid)
+{
+ 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);
+}
+
+/**
+ * build inode generation from passed @fid. If our FID overflows the 32-bit
+ * inode number then return a non-zero generation to distinguish them. */
+__u32 cl_fid_build_gen(const struct lu_fid *fid)
+{
+ __u32 gen;
+ ENTRY;
+
+ if (fid_is_igif(fid)) {
+ gen = lu_igif_gen(fid);
+ RETURN(gen);
+ }
+
+ gen = (fid_flatten(fid) >> 32);
+ RETURN(gen);
+}