-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011 Whamcloud, Inc.
- *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
struct ccc_io *vio, struct cl_io *io)
{
struct ccc_thread_info *cti = ccc_env_info(env);
+ struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
struct cl_lock_descr *descr = &cti->cti_descr;
ldlm_policy_data_t policy;
if (!cl_is_normalio(env, io))
RETURN(0);
+ if (vio->cui_iov == NULL) /* nfs or loop back device write */
+ RETURN(0);
+
+ /* No MM (e.g. NFS)? No vmas too. */
+ if (mm == NULL)
+ RETURN(0);
+
for (seg = 0; seg < vio->cui_nrsegs; seg++) {
const struct iovec *iv = &vio->cui_iov[seg];
count += addr & (~CFS_PAGE_MASK);
addr &= CFS_PAGE_MASK;
- while((vma = our_vma(addr, count)) != NULL) {
+
+ down_read(&mm->mmap_sem);
+ while((vma = our_vma(mm, addr, count)) != NULL) {
struct inode *inode = vma->vm_file->f_dentry->d_inode;
int flags = CEF_MUST;
if (ll_file_nolock(vma->vm_file)) {
- /*
+ /*
* For no lock case, a lockless lock will be
* generated.
*/
count -= vma->vm_end - addr;
addr = vma->vm_end;
}
+ up_read(&mm->mmap_sem);
}
RETURN(0);
}
return result;
}
+static void vvp_io_fsync_end(const struct lu_env *env,
+ const struct cl_io_slice *ios)
+{
+ /* never try to verify there is no dirty pages in sync range
+ * because page_mkwrite() can generate new dirty pages any time. */
+}
+
static int vvp_io_read_page(const struct lu_env *env,
const struct cl_io_slice *ios,
const struct cl_page_slice *slice)
.cio_start = vvp_io_fault_start,
.cio_end = ccc_io_end
},
+ [CIT_FSYNC] = {
+ .cio_end = vvp_io_fsync_end,
+ .cio_fini = vvp_io_fini
+ },
[CIT_MISC] = {
.cio_fini = vvp_io_fini
}
{
struct vvp_io *vio = vvp_env_io(env);
struct ccc_io *cio = ccc_env_io(env);
- struct inode *inode = ccc_object_inode(obj);
- struct ll_sb_info *sbi = ll_i2sbi(inode);
int result;
CLOBINVRNT(env, obj, ccc_object_invariant(obj));
result = 0;
if (io->ci_type == CIT_READ || io->ci_type == CIT_WRITE) {
size_t count;
+ struct ll_inode_info *lli = ll_i2info(ccc_object_inode(obj));
count = io->u.ci_rw.crw_count;
/* "If nbyte is 0, read() will return 0 and have no other
cio->cui_tot_count = count;
cio->cui_tot_nrsegs = 0;
}
+ /* for read/write, we store the jobid in the inode, and
+ * it'll be fetched by osc when building RPC.
+ *
+ * it's not accurate if the file is shared by different
+ * jobs.
+ */
+ lustre_get_jobid(lli->lli_jobid);
} else if (io->ci_type == CIT_SETATTR) {
- if (cl_io_is_trunc(io))
- /* lockless truncate? */
- ll_stats_ops_tally(sbi, LPROC_LL_TRUNC, 1);
- else
+ if (!cl_io_is_trunc(io))
io->ci_lockreq = CILR_MANDATORY;
}
RETURN(result);