*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, 2015, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
iobuf->dr_rw = rw;
iobuf->dr_init_at = line;
- blocks = pages * (PAGE_CACHE_SIZE >> osd_sb(d)->s_blocksize_bits);
+ blocks = pages * (PAGE_SIZE >> osd_sb(d)->s_blocksize_bits);
if (iobuf->dr_bl_buf.lb_len >= blocks * sizeof(iobuf->dr_blocks[0])) {
LASSERT(iobuf->dr_pg_buf.lb_len >=
pages * sizeof(iobuf->dr_pages[0]));
CDEBUG(D_OTHER, "realloc %u for %u (%u) pages\n",
(unsigned)(pages * sizeof(iobuf->dr_pages[0])), i, pages);
pages = i;
- blocks = pages * (PAGE_CACHE_SIZE >> osd_sb(d)->s_blocksize_bits);
+ blocks = pages * (PAGE_SIZE >> osd_sb(d)->s_blocksize_bits);
iobuf->dr_max_pages = 0;
CDEBUG(D_OTHER, "realloc %u for %u blocks\n",
(unsigned)(blocks * sizeof(iobuf->dr_blocks[0])), blocks);
#define __REQ_WRITE BIO_RW
#endif
+#ifdef HAVE_BIO_ENDIO_USES_ONE_ARG
+static void dio_complete_routine(struct bio *bio)
+{
+ int error = bio->bi_error;
+#else
static void dio_complete_routine(struct bio *bio, int error)
{
+#endif
struct osd_iobuf *iobuf = bio->bi_private;
-#ifdef HAVE_BVEC_ITER
- struct bvec_iter iter;
- struct bio_vec bvl;
-#else
int iter;
struct bio_vec *bvl;
-#endif
/* CAVEAT EMPTOR: possibly in IRQ context
* DO NOT record procfs stats here!!! */
"IO - you will probably have to reboot this node.\n");
CERROR("bi_next: %p, bi_flags: %lx, bi_rw: %lu, bi_vcnt: %d, "
"bi_idx: %d, bi->size: %d, bi_end_io: %p, bi_cnt: %d, "
- "bi_private: %p\n", bio->bi_next, bio->bi_flags,
+ "bi_private: %p\n", bio->bi_next,
+ (unsigned long)bio->bi_flags,
bio->bi_rw, bio->bi_vcnt, bio_idx(bio),
bio_sectors(bio) << 9, bio->bi_end_io,
- atomic_read(&bio->bi_cnt), bio->bi_private);
+#ifdef HAVE_BI_CNT
+ atomic_read(&bio->bi_cnt),
+#else
+ atomic_read(&bio->__bi_cnt),
+#endif
+ bio->bi_private);
return;
}
/* the check is outside of the cycle for performance reason -bzzz */
if (!test_bit(__REQ_WRITE, &bio->bi_rw)) {
- bio_for_each_segment(bvl, bio, iter) {
+ bio_for_each_segment_all(bvl, bio, iter) {
if (likely(error == 0))
SetPageUptodate(bvl_to_page(bvl));
LASSERT(PageLocked(bvl_to_page(bvl)));
static int osd_do_bio(struct osd_device *osd, struct inode *inode,
struct osd_iobuf *iobuf)
{
- int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
+ int blocks_per_page = PAGE_SIZE >> inode->i_blkbits;
struct page **pages = iobuf->dr_pages;
int npages = iobuf->dr_npages;
sector_t *blocks = iobuf->dr_blocks;
*nrpages = 0;
while (len > 0) {
- int poff = offset & (PAGE_CACHE_SIZE - 1);
- int plen = PAGE_CACHE_SIZE - poff;
+ int poff = offset & (PAGE_SIZE - 1);
+ int plen = PAGE_SIZE - poff;
if (plen > len)
plen = len;
LASSERT(inode);
- page = find_or_create_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT,
+ page = find_or_create_page(inode->i_mapping, offset >> PAGE_SHIFT,
GFP_NOFS | __GFP_HIGHMEM);
if (unlikely(page == NULL))
lprocfs_counter_add(d->od_stats, LPROC_OSD_NO_PAGE, 1);
continue;
LASSERT(PageLocked(lnb[i].lnb_page));
unlock_page(lnb[i].lnb_page);
- page_cache_release(lnb[i].lnb_page);
+ put_page(lnb[i].lnb_page);
lu_object_put(env, &dt->do_lu);
lnb[i].lnb_page = NULL;
}
static int osd_ldiskfs_map_nblocks(struct inode *inode, unsigned long index,
int clen, sector_t *blocks, int create)
{
- int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
+ int blocks_per_page = PAGE_SIZE >> inode->i_blkbits;
struct bpointers bp;
int err;
struct page **page, int pages,
sector_t *blocks, int create)
{
- int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
+ int blocks_per_page = PAGE_SIZE >> inode->i_blkbits;
pgoff_t bitmap_max_page_index;
sector_t *b;
int rc = 0, i;
/* look for next extent */
fp = NULL;
- blocks += clen * (PAGE_CACHE_SIZE >> inode->i_blkbits);
+ blocks += clen * (PAGE_SIZE >> inode->i_blkbits);
}
if (fp)
int pages, sector_t *blocks,
int create)
{
- int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
+ int blocks_per_page = PAGE_SIZE >> inode->i_blkbits;
int rc = 0, i = 0;
struct page *fp = NULL;
int clen = 0;
pgoff_t max_page_index;
+ handle_t *handle = NULL;
max_page_index = inode->i_sb->s_maxbytes >> PAGE_SHIFT;
CDEBUG(D_OTHER, "inode %lu: map %d pages from %lu\n",
inode->i_ino, pages, (*page)->index);
+ if (create) {
+ create = LDISKFS_GET_BLOCKS_CREATE;
+ handle = ldiskfs_journal_current_handle();
+ LASSERT(handle != NULL);
+ rc = osd_attach_jinode(inode);
+ if (rc)
+ return rc;
+ }
/* pages are sorted already. so, we just have to find
* contig. space and process them properly */
while (i < pages) {
long blen, total = 0;
- handle_t *handle = NULL;
struct ldiskfs_map_blocks map = { 0 };
if (fp == NULL) { /* start new extent */
/* process found extent */
map.m_lblk = fp->index * blocks_per_page;
map.m_len = blen = clen * blocks_per_page;
- if (create) {
- create = LDISKFS_GET_BLOCKS_CREATE;
- handle = ldiskfs_journal_current_handle();
- LASSERT(handle != NULL);
- }
cont_map:
rc = ldiskfs_map_blocks(handle, inode, &map, create);
if (rc >= 0) {
struct osd_iobuf *iobuf = &oti->oti_iobuf;
struct inode *inode = osd_dt_obj(dt)->oo_inode;
struct osd_device *osd = osd_obj2dev(osd_dt_obj(dt));
- struct timeval start;
- struct timeval end;
- unsigned long timediff;
+ ktime_t start;
+ ktime_t end;
+ s64 timediff;
ssize_t isize;
__s64 maxidx;
int rc = 0;
RETURN(rc);
isize = i_size_read(inode);
- maxidx = ((isize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT) - 1;
+ maxidx = ((isize + PAGE_SIZE - 1) >> PAGE_SHIFT) - 1;
if (osd->od_writethrough_cache)
cache = 1;
if (isize > osd->od_readcache_max_filesize)
cache = 0;
- do_gettimeofday(&start);
+ start = ktime_get();
for (i = 0; i < npages; i++) {
if (cache == 0)
*/
ClearPageUptodate(lnb[i].lnb_page);
- if (lnb[i].lnb_len == PAGE_CACHE_SIZE)
+ if (lnb[i].lnb_len == PAGE_SIZE)
continue;
if (maxidx >= lnb[i].lnb_page->index) {
off = (lnb[i].lnb_page_offset + lnb[i].lnb_len) &
~PAGE_MASK;
if (off)
- memset(p + off, 0, PAGE_CACHE_SIZE - off);
+ memset(p + off, 0, PAGE_SIZE - off);
kunmap(lnb[i].lnb_page);
}
}
- do_gettimeofday(&end);
- timediff = cfs_timeval_sub(&end, &start, NULL);
+ end = ktime_get();
+ timediff = ktime_us_delta(end, start);
lprocfs_counter_add(osd->od_stats, LPROC_OSD_GET_PAGE, timediff);
if (iobuf->dr_npages) {
extents++;
if (!osd_is_mapped(dt, lnb[i].lnb_file_offset, &extent))
- quota_space += PAGE_CACHE_SIZE;
+ quota_space += PAGE_SIZE;
/* ignore quota for the whole request if any page is from
* client cache or written by root.
thandle->th_local = 1;
}
- if (likely(rc == 0)) {
- if (isize > i_size_read(inode)) {
- i_size_write(inode, isize);
- LDISKFS_I(inode)->i_disksize = isize;
+ if (likely(rc == 0)) {
+ spin_lock(&inode->i_lock);
+ if (isize > i_size_read(inode)) {
+ i_size_write(inode, isize);
+ LDISKFS_I(inode)->i_disksize = isize;
+ spin_unlock(&inode->i_lock);
ll_dirty_inode(inode, I_DIRTY_DATASYNC);
- }
+ } else {
+ spin_unlock(&inode->i_lock);
+ }
- rc = osd_do_bio(osd, inode, iobuf);
- /* we don't do stats here as in read path because
- * write is async: we'll do this in osd_put_bufs() */
+ rc = osd_do_bio(osd, inode, iobuf);
+ /* we don't do stats here as in read path because
+ * write is async: we'll do this in osd_put_bufs() */
} else {
osd_fini_iobuf(osd, iobuf);
}
struct osd_iobuf *iobuf = &oti->oti_iobuf;
struct inode *inode = osd_dt_obj(dt)->oo_inode;
struct osd_device *osd = osd_obj2dev(osd_dt_obj(dt));
- struct timeval start, end;
- unsigned long timediff;
int rc = 0, i, cache = 0, cache_hits = 0, cache_misses = 0;
+ ktime_t start, end;
+ s64 timediff;
loff_t isize;
LASSERT(inode);
if (isize > osd->od_readcache_max_filesize)
cache = 0;
- do_gettimeofday(&start);
+ start = ktime_get();
for (i = 0; i < npages; i++) {
if (isize <= lnb[i].lnb_file_offset)
else
lnb[i].lnb_rc = lnb[i].lnb_len;
+ /* Bypass disk read if fail_loc is set properly */
+ if (OBD_FAIL_CHECK(OBD_FAIL_OST_FAKE_RW))
+ SetPageUptodate(lnb[i].lnb_page);
+
if (PageUptodate(lnb[i].lnb_page)) {
cache_hits++;
} else {
generic_error_remove_page(inode->i_mapping,
lnb[i].lnb_page);
}
- do_gettimeofday(&end);
- timediff = cfs_timeval_sub(&end, &start, NULL);
+ end = ktime_get();
+ timediff = ktime_us_delta(end, start);
lprocfs_counter_add(osd->od_stats, LPROC_OSD_GET_PAGE, timediff);
if (cache_hits != 0)
int blocksize;
int csize;
int boffs;
- int err = 0;
/* prevent reading after eof */
spin_lock(&inode->i_lock);
block = *offs >> inode->i_blkbits;
boffs = *offs & (blocksize - 1);
csize = min(blocksize - boffs, size);
- bh = ldiskfs_bread(NULL, inode, block, 0, &err);
- if (err != 0) {
- CERROR("%s: can't read %u@%llu on ino %lu: rc = %d\n",
+ bh = __ldiskfs_bread(NULL, inode, block, 0);
+ if (IS_ERR(bh)) {
+ CERROR("%s: can't read %u@%llu on ino %lu: rc = %ld\n",
LDISKFS_SB(inode->i_sb)->s_es->s_volume_name,
- csize, *offs, inode->i_ino, err);
- if (bh != NULL)
- brelse(bh);
- return err;
+ csize, *offs, inode->i_ino,
+ PTR_ERR(bh));
+ return PTR_ERR(bh);
}
if (bh != NULL) {
/* LU-2634: clear the extent format for fast symlink */
ldiskfs_clear_inode_flag(inode, LDISKFS_INODE_EXTENTS);
- memcpy((char *)&LDISKFS_I(inode)->i_data, (char *)buffer, buflen);
- LDISKFS_I(inode)->i_disksize = buflen;
- i_size_write(inode, buflen);
+ memcpy((char *)&LDISKFS_I(inode)->i_data, (char *)buffer, buflen);
+ spin_lock(&inode->i_lock);
+ LDISKFS_I(inode)->i_disksize = buflen;
+ i_size_write(inode, buflen);
+ spin_unlock(&inode->i_lock);
ll_dirty_inode(inode, I_DIRTY_DATASYNC);
- return 0;
+ return 0;
}
int osd_ldiskfs_write_record(struct inode *inode, void *buf, int bufsize,
if (bh != NULL)
brelse(bh);
- block = offset >> inode->i_blkbits;
- boffs = offset & (blocksize - 1);
- size = min(blocksize - boffs, bufsize);
- bh = ldiskfs_bread(handle, inode, block, 1, &err);
- if (!bh) {
- err = err ? err : -EIO;
+ block = offset >> inode->i_blkbits;
+ boffs = offset & (blocksize - 1);
+ size = min(blocksize - boffs, bufsize);
+ bh = __ldiskfs_bread(handle, inode, block, 1);
+ if (IS_ERR_OR_NULL(bh)) {
+ if (bh == NULL) {
+ err = -EIO;
+ } else {
+ err = PTR_ERR(bh);
+ bh = NULL;
+ }
CERROR("%s: error reading offset %llu (block %lu): "
"rc = %d\n",
inode->i_sb->s_id, offset, block, err);
if (write_NUL)
--new_size;
- /* correct in-core and on-disk sizes */
- if (new_size > i_size_read(inode)) {
+ /* correct in-core and on-disk sizes */
+ if (new_size > i_size_read(inode)) {
spin_lock(&inode->i_lock);
if (new_size > i_size_read(inode))
i_size_write(inode, new_size);
tid = oh->ot_handle->h_transaction->t_tid;
+ spin_lock(&inode->i_lock);
i_size_write(inode, start);
+ spin_unlock(&inode->i_lock);
ll_truncate_pagecache(inode, start);
#ifdef HAVE_INODEOPS_TRUNCATE
if (inode->i_op->truncate) {
static int osd_ladvise(const struct lu_env *env, struct dt_object *dt,
__u64 start, __u64 end, enum lu_ladvise_type advice)
{
- int rc;
+ int rc = 0;
+ struct inode *inode = osd_dt_obj(dt)->oo_inode;
ENTRY;
switch (advice) {
+ case LU_LADVISE_DONTNEED:
+ if (end == 0)
+ break;
+ invalidate_mapping_pages(inode->i_mapping,
+ start >> PAGE_CACHE_SHIFT,
+ (end - 1) >> PAGE_CACHE_SHIFT);
+ break;
default:
rc = -ENOTSUPP;
break;
.dbo_fiemap_get = osd_fiemap_get,
.dbo_ladvise = osd_ladvise,
};
-