Whamcloud - gitweb
LU-8210 osd-ldiskfs: fix setting pages PageUptodate state
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_io.c
index 98da270..aaea2f0 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -179,7 +179,7 @@ static void dio_complete_routine(struct bio *bio, int error)
 
        /* 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)));
@@ -1337,7 +1337,7 @@ static int osd_read_prep(const struct lu_env *env, struct dt_object *dt,
                         * lnb->lnb_rc == 0, so it's easy to detect later. */
                        break;
 
-               if (isize < lnb[i].lnb_file_offset + lnb[i].lnb_len - 1)
+               if (isize < lnb[i].lnb_file_offset + lnb[i].lnb_len)
                        lnb[i].lnb_rc = isize - lnb[i].lnb_file_offset;
                else
                        lnb[i].lnb_rc = lnb[i].lnb_len;
@@ -1488,11 +1488,9 @@ static inline int osd_extents_enabled(struct super_block *sb,
        return 0;
 }
 
-static inline int osd_calc_bkmap_credits(struct super_block *sb,
-                                        struct inode *inode,
-                                        const loff_t size,
-                                        const loff_t pos,
-                                        const int blocks)
+int osd_calc_bkmap_credits(struct super_block *sb, struct inode *inode,
+                          const loff_t size, const loff_t pos,
+                          const int blocks)
 {
        int credits, bits, bs, i;
 
@@ -1527,9 +1525,12 @@ static inline int osd_calc_bkmap_credits(struct super_block *sb,
        } else if (pos + size <= (LDISKFS_NDIR_BLOCKS + 1024) * bs) {
                /* single indirect */
                credits = blocks * 3;
-               /* probably indirect block has been allocated already */
-               if (!inode || LDISKFS_I(inode)->i_data[LDISKFS_IND_BLOCK])
+               if (inode == NULL ||
+                   LDISKFS_I(inode)->i_data[LDISKFS_IND_BLOCK] == 0)
                        credits += 3;
+               else
+                       /* The indirect block may be modified. */
+                       credits += 1;
        }
 
        return credits;
@@ -1918,6 +1919,21 @@ static int osd_fiemap_get(const struct lu_env *env, struct dt_object *dt,
        return rc;
 }
 
+static int osd_ladvise(const struct lu_env *env, struct dt_object *dt,
+                      __u64 start, __u64 end, enum lu_ladvise_type advice)
+{
+       int     rc;
+       ENTRY;
+
+       switch (advice) {
+       default:
+               rc = -ENOTSUPP;
+               break;
+       }
+
+       RETURN(rc);
+}
+
 /*
  * in some cases we may need declare methods for objects being created
  * e.g., when we create symlink
@@ -1927,17 +1943,18 @@ const struct dt_body_operations osd_body_ops_new = {
 };
 
 const struct dt_body_operations osd_body_ops = {
-        .dbo_read                 = osd_read,
-        .dbo_declare_write        = osd_declare_write,
-        .dbo_write                = osd_write,
-        .dbo_bufs_get             = osd_bufs_get,
-        .dbo_bufs_put             = osd_bufs_put,
-        .dbo_write_prep           = osd_write_prep,
-        .dbo_declare_write_commit = osd_declare_write_commit,
-        .dbo_write_commit         = osd_write_commit,
-        .dbo_read_prep            = osd_read_prep,
-        .dbo_declare_punch         = osd_declare_punch,
-        .dbo_punch                 = osd_punch,
-        .dbo_fiemap_get           = osd_fiemap_get,
+       .dbo_read                       = osd_read,
+       .dbo_declare_write              = osd_declare_write,
+       .dbo_write                      = osd_write,
+       .dbo_bufs_get                   = osd_bufs_get,
+       .dbo_bufs_put                   = osd_bufs_put,
+       .dbo_write_prep                 = osd_write_prep,
+       .dbo_declare_write_commit       = osd_declare_write_commit,
+       .dbo_write_commit               = osd_write_commit,
+       .dbo_read_prep                  = osd_read_prep,
+       .dbo_declare_punch              = osd_declare_punch,
+       .dbo_punch                      = osd_punch,
+       .dbo_fiemap_get                 = osd_fiemap_get,
+       .dbo_ladvise                    = osd_ladvise,
 };