Whamcloud - gitweb
LU-9031 osd: handle jinode change for ldiskfs 41/24941/11
authorYang Sheng <yang.sheng@intel.com>
Mon, 23 Jan 2017 19:31:27 +0000 (03:31 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 3 Feb 2017 00:25:51 +0000 (00:25 +0000)
We need take care of jinode for ldiskfs. Since we
didn't got inode from syscall like sys_open(). So
have to initailize it in OSD by ourselves.

Signed-off-by: Yang Sheng <yang.sheng@intel.com>
Change-Id: Iec6db290c3779a8f7c98e5d1356b71fd928d7c88
Reviewed-on: https://review.whamcloud.com/24941
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
ldiskfs/kernel_patches/patches/sles12sp2/ext4-attach-jinode-in-writepages.patch [new file with mode: 0644]
ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_io.c

diff --git a/ldiskfs/kernel_patches/patches/sles12sp2/ext4-attach-jinode-in-writepages.patch b/ldiskfs/kernel_patches/patches/sles12sp2/ext4-attach-jinode-in-writepages.patch
new file mode 100644 (file)
index 0000000..3c1d8e0
--- /dev/null
@@ -0,0 +1,30 @@
+--- l1/fs/ext4/inode.c 2016-08-23 23:38:23.238091149 +0800
++++ l2/fs/ext4/inode.c 2017-01-24 04:04:45.100092653 +0800
+@@ -2683,6 +2683,9 @@ static int ext4_writepages(struct addres
+               mpd.last_page = wbc->range_end >> PAGE_CACHE_SHIFT;
+       }
++      ret = ext4_inode_attach_jinode(inode);
++      if (ret)
++              goto out_writepages;
+       mpd.inode = inode;
+       mpd.wbc = wbc;
+       ext4_io_submit_init(&mpd.io_submit, wbc);
+@@ -4015,6 +4015,7 @@ int ext4_inode_attach_jinode(struct inod
+               jbd2_free_inode(jinode);
+       return 0;
+ }
++EXPORT_SYMBOL(ext4_inode_attach_jinode);
+ /*
+  * ext4_truncate()
+--- l1/fs/ext4/ext4.h  2017-01-24 04:21:28.989470587 +0800
++++ l2/fs/ext4/ext4.h  2017-01-24 04:32:45.589800986 +0800
+@@ -2462,6 +2462,7 @@ extern int ext4_group_add_blocks(handle_
+ extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
+ /* inode.c */
++#define HAVE_LDISKFS_INFO_JINODE
+ int ext4_inode_is_fast_symlink(struct inode *inode);
+ struct buffer_head *ext4_getblk(handle_t *, struct inode *, ext4_lblk_t, int);
+ struct buffer_head *ext4_bread(handle_t *, struct inode *, ext4_lblk_t, int);
index 0f8ba37..3fe547b 100644 (file)
@@ -20,3 +20,4 @@ sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 sles12sp2/ext4-give-warning-with-dir-htree-growing.patch
 sles12sp2/ext4-mmp-brelse.patch
 rhel7/ext4-jcb-optimization.patch
+sles12sp2/ext4-attach-jinode-in-writepages.patch
index 9265aec..d10626d 100644 (file)
@@ -385,6 +385,7 @@ int osd_get_lma(struct osd_thread_info *info, struct inode *inode,
 struct inode *osd_iget(struct osd_thread_info *info, struct osd_device *dev,
                       struct osd_inode_id *id)
 {
+       int rc;
        struct inode *inode = NULL;
 
        /* if we look for an inode withing a running
@@ -414,6 +415,9 @@ struct inode *osd_iget(struct osd_thread_info *info, struct osd_device *dev,
                LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name, id->oii_ino);
                iput(inode);
                inode = ERR_PTR(-ENOENT);
+       } else if ((rc = osd_attach_jinode(inode))) {
+               iput(inode);
+               inode = ERR_PTR(rc);
        } else {
                ldiskfs_clear_inode_state(inode, LDISKFS_STATE_LUSTRE_DESTROY);
                if (id->oii_gen == OSD_OII_NOGEN)
@@ -1191,6 +1195,13 @@ found:
            (flags & SS_AUTO_PARTIAL || sf->sf_status == SS_SCANNING))
                osd_check_lmv(info, dev, inode, oic);
 
+       result = osd_attach_jinode(inode);
+       if (result) {
+               obj->oo_inode = NULL;
+               iput(inode);
+               GOTO(out, result);
+       }
+
        if (!ldiskfs_pdo)
                GOTO(out, result = 0);
 
index 5fa0305..453580f 100644 (file)
@@ -772,11 +772,26 @@ static inline void i_gid_write(struct inode *inode, gid_t gid)
 }
 #endif
 
+#ifdef HAVE_LDISKFS_INFO_JINODE
+# define osd_attach_jinode(inode) ldiskfs_inode_attach_jinode(inode)
+#else  /* HAVE_LDISKFS_INFO_JINODE */
+# define osd_attach_jinode(inode) 0
+#endif /* HAVE_LDISKFS_INFO_JINODE */
+
 #ifdef LDISKFS_HT_MISC
 # define osd_journal_start_sb(sb, type, nblock) \
                ldiskfs_journal_start_sb(sb, type, nblock)
-# define osd_ldiskfs_append(handle, inode, nblock) \
-               ldiskfs_append(handle, inode, nblock)
+static inline struct buffer_head *osd_ldiskfs_append(handle_t *handle,
+                                                    struct inode *inode,
+                                                    ldiskfs_lblk_t *nblock)
+{
+       int rc;
+
+       rc = osd_attach_jinode(inode);
+       if (rc)
+               return ERR_PTR(rc);
+       return ldiskfs_append(handle, inode, nblock);
+}
 # define osd_ldiskfs_find_entry(dir, name, de, inlined, lock) \
                (__ldiskfs_find_entry(dir, name, de, inlined, lock) ?: \
                 ERR_PTR(-ENOENT))
@@ -1213,18 +1228,23 @@ static inline struct buffer_head *__ldiskfs_bread(handle_t *handle,
                                                  ldiskfs_lblk_t block,
                                                  int create)
 {
-#ifdef HAVE_EXT4_BREAD_4ARGS
-       return ldiskfs_bread(handle, inode, block, create);
-#else
+       int rc = 0;
        struct buffer_head *bh;
-       int error = 0;
 
-       bh = ldiskfs_bread(handle, inode, block, create, &error);
-       if (bh == NULL && error != 0)
-               bh = ERR_PTR(error);
+       if (create) {
+               rc = osd_attach_jinode(inode);
+               if (rc)
+                       return ERR_PTR(rc);
+       }
+#ifdef HAVE_EXT4_BREAD_4ARGS
+       bh = ldiskfs_bread(handle, inode, block, create);
+#else
 
-       return bh;
+       bh = ldiskfs_bread(handle, inode, block, create, &rc);
+       if (bh == NULL && rc != 0)
+               bh = ERR_PTR(rc);
 #endif
+       return bh;
 }
 
 void ldiskfs_inc_count(handle_t *handle, struct inode *inode);
@@ -1232,4 +1252,5 @@ void ldiskfs_dec_count(handle_t *handle, struct inode *inode);
 
 void osd_fini_iobuf(struct osd_device *d, struct osd_iobuf *iobuf);
 
+
 #endif /* _OSD_INTERNAL_H */
index abc47fc..7713af9 100644 (file)
@@ -887,17 +887,25 @@ static int osd_ldiskfs_map_inode_pages(struct inode *inode, struct page **page,
        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 */
@@ -917,11 +925,6 @@ static int osd_ldiskfs_map_inode_pages(struct inode *inode, struct page **page,
                /* 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) {