Blob Blame History Raw
From d1191e2f2315920d5f3c4cfcc48955a9a23d7ae4 Mon Sep 17 00:00:00 2001
From: Pranith Kumar K <pkarampu@redhat.com>
Date: Wed, 26 Oct 2016 06:51:18 +0530
Subject: [PATCH 146/157] afr,ec: Heal device files with correct major, minor numbers

Thanks a lot to xiaoping.wu@nokia.com from Nokia for the bug and the
fix.

 >BUG: 1384297
 >Change-Id: Ie443237e85d34633b5dd30f85eaa2ac34e45754c
 >Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
 >Reviewed-on: http://review.gluster.org/15728
 >Smoke: Gluster Build System <jenkins@build.gluster.org>
 >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
 >Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
 >CentOS-regression: Gluster Build System <jenkins@build.gluster.org>

 >Change-Id: Ie7977caf7c98c91fca64752c56731c37ad27df4d
 >BUG: 1388912
 >Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
 >Reviewed-on: http://review.gluster.org/15734
 >Smoke: Gluster Build System <jenkins@build.gluster.org>
 >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
 >CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
 >Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>

BUG: 1388734
Change-Id: I0880fd6de5e861005e2c759fc66d19e4758cb748
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/88425
---
 tests/basic/afr/entry-self-heal.t             |   28 ++++++++++++++++---------
 tests/basic/ec/ec-new-entry.t                 |    6 ++++-
 xlators/cluster/afr/src/afr-self-heal-entry.c |    3 +-
 xlators/cluster/ec/src/ec-heal.c              |    3 +-
 4 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/tests/basic/afr/entry-self-heal.t b/tests/basic/afr/entry-self-heal.t
index f077672..337b9c5 100644
--- a/tests/basic/afr/entry-self-heal.t
+++ b/tests/basic/afr/entry-self-heal.t
@@ -92,24 +92,24 @@ cd $M0
 
 TEST mkdir spb_heal spb spb_me_heal spb_me fool_heal fool_me v1_fool_heal v1_fool_me source_creations_heal source_deletions_heal source_creations_me source_deletions_me v1_dirty_me v1_dirty_heal source_self_accusing
 TEST mkfifo source_deletions_heal/fifo
-TEST mknod  source_deletions_heal/block b 0 0
-TEST mknod  source_deletions_heal/char c 0 0
+TEST mknod  source_deletions_heal/block b 4 5
+TEST mknod  source_deletions_heal/char c 1 5
 TEST touch  source_deletions_heal/file
 TEST ln -s  source_deletions_heal/file source_deletions_heal/slink
 TEST mkdir  source_deletions_heal/dir1
 TEST mkdir  source_deletions_heal/dir1/dir2
 
 TEST mkfifo source_deletions_me/fifo
-TEST mknod  source_deletions_me/block b 0 0
-TEST mknod  source_deletions_me/char c 0 0
+TEST mknod  source_deletions_me/block b 4 5
+TEST mknod  source_deletions_me/char c 1 5
 TEST touch  source_deletions_me/file
 TEST ln -s  source_deletions_me/file source_deletions_me/slink
 TEST mkdir  source_deletions_me/dir1
 TEST mkdir  source_deletions_me/dir1/dir2
 
 TEST mkfifo source_self_accusing/fifo
-TEST mknod  source_self_accusing/block b 0 0
-TEST mknod  source_self_accusing/char c 0 0
+TEST mknod  source_self_accusing/block b 4 5
+TEST mknod  source_self_accusing/char c 1 5
 TEST touch  source_self_accusing/file
 TEST ln -s  source_self_accusing/file source_self_accusing/slink
 TEST mkdir  source_self_accusing/dir1
@@ -144,16 +144,16 @@ TEST ! stat $B0/${V0}1/source_self_accusing/dir1
 
 
 TEST mkfifo source_creations_heal/fifo
-TEST mknod  source_creations_heal/block b 0 0
-TEST mknod  source_creations_heal/char c 0 0
+TEST mknod  source_creations_heal/block b 4 5
+TEST mknod  source_creations_heal/char c 1 5
 TEST touch  source_creations_heal/file
 TEST ln -s  source_creations_heal/file source_creations_heal/slink
 TEST mkdir  source_creations_heal/dir1
 TEST mkdir  source_creations_heal/dir1/dir2
 
 TEST mkfifo source_creations_me/fifo
-TEST mknod  source_creations_me/block b 0 0
-TEST mknod  source_creations_me/char c 0 0
+TEST mknod  source_creations_me/block b 4 5
+TEST mknod  source_creations_me/char c 1 5
 TEST touch  source_creations_me/file
 TEST ln -s  source_creations_me/file source_creations_me/slink
 TEST mkdir  source_creations_me/dir1
@@ -255,11 +255,15 @@ TEST [ -p source_creations_me/fifo ]
 r=$(get_file_type source_creations_me/block)
 EXPECT "$r" get_file_type $B0/${V0}0/source_creations_me/block
 EXPECT "$r" get_file_type $B0/${V0}1/source_creations_me/block
+EXPECT "^4 5$" stat -c "%t %T" $B0/${V0}1/source_creations_me/block
+EXPECT "^4 5$" stat -c "%t %T" $B0/${V0}0/source_creations_me/block
 TEST [ -b source_creations_me/block ]
 
 r=$(get_file_type source_creations_me/char)
 EXPECT "$r" get_file_type $B0/${V0}0/source_creations_me/char
 EXPECT "$r" get_file_type $B0/${V0}1/source_creations_me/char
+EXPECT "^1 5$" stat -c "%t %T" $B0/${V0}1/source_creations_me/char
+EXPECT "^1 5$" stat -c "%t %T" $B0/${V0}0/source_creations_me/char
 TEST [ -c source_creations_me/char ]
 
 r=$(get_file_type source_creations_me/file)
@@ -408,12 +412,16 @@ TEST ! stat $B0/${V0}1/source_self_accusing/dir1
 r=$(get_file_type $B0/${V0}0/source_creations_heal/fifo)
 EXPECT "$r" get_file_type $B0/${V0}1/source_creations_heal/fifo
 TEST [ -p $B0/${V0}0/source_creations_heal/fifo ]
+EXPECT "^4 5$" stat -c "%t %T" $B0/${V0}1/source_creations_heal/block
+EXPECT "^4 5$" stat -c "%t %T" $B0/${V0}0/source_creations_heal/block
 
 r=$(get_file_type $B0/${V0}0/source_creations_heal/block)
 EXPECT "$r" get_file_type $B0/${V0}1/source_creations_heal/block
 
 r=$(get_file_type $B0/${V0}0/source_creations_heal/char)
 EXPECT "$r" get_file_type $B0/${V0}1/source_creations_heal/char
+EXPECT "^1 5$" stat -c "%t %T" $B0/${V0}1/source_creations_heal/char
+EXPECT "^1 5$" stat -c "%t %T" $B0/${V0}0/source_creations_heal/char
 
 r=$(get_file_type $B0/${V0}0/source_creations_heal/file)
 EXPECT "$r" get_file_type $B0/${V0}1/source_creations_heal/file
diff --git a/tests/basic/ec/ec-new-entry.t b/tests/basic/ec/ec-new-entry.t
index 2ba2bf5..be97aec 100644
--- a/tests/basic/ec/ec-new-entry.t
+++ b/tests/basic/ec/ec-new-entry.t
@@ -31,6 +31,8 @@ TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $
 EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0
 touch $M0/{1..10}
 touch $M0/11
+TEST mknod $M0/char c 1 5
+TEST mknod $M0/block b 4 5
 for i in {1..10}; do dd if=/dev/zero of=$M0/$i bs=1M count=1; done
 TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}5 $H0:$B0/${V0}6 commit force
 EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0
@@ -39,7 +41,9 @@ EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count_shd $V0 0
 EXPECT_WITHIN $HEAL_TIMEOUT "Y" root_heal_attempted $B0/${V0}6
 EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
 #ls -l gives "Total" line so number of lines will be 1 more
-EXPECT "^12$" num_entries $B0/${V0}6
+EXPECT "^14$" num_entries $B0/${V0}6
+EXPECT "^1 5$" stat -c "%t %T" $B0/${V0}6/char
+EXPECT "^4 5$" stat -c "%t %T" $B0/${V0}6/block
 ec_version=$(get_hex_xattr trusted.ec.version $B0/${V0}0)
 EXPECT "$ec_version" get_hex_xattr trusted.ec.version $B0/${V0}1
 EXPECT "$ec_version" get_hex_xattr trusted.ec.version $B0/${V0}2
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
index fb904f3..add9e28 100644
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
@@ -145,7 +145,8 @@ afr_selfheal_recreate_entry (xlator_t *this, int dst, int source, inode_t *dir,
 		if (ret)
 			goto out;
 		ret = syncop_mknod (priv->children[dst], &loc, mode,
-				    iatt->ia_rdev, &newent, xdata, NULL);
+                    makedev (ia_major(iatt->ia_rdev), ia_minor (iatt->ia_rdev)),
+                    &newent, xdata, NULL);
 		if (ret == 0 && newent.ia_nlink == 1) {
 			/* New entry created. Mark @dst pending on all sources */
                         newentry[dst] = 1;
diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c
index 39cce19..f86b2cd 100644
--- a/xlators/cluster/ec/src/ec-heal.c
+++ b/xlators/cluster/ec/src/ec-heal.c
@@ -1148,7 +1148,8 @@ ec_create_name (call_frame_t *frame, ec_t *ec, inode_t *parent, char *name,
                                      replies, output, frame, ec->xl,
                                      &loc, st_mode_from_ia (ia->ia_prot,
                                                            ia->ia_type),
-                                     ia->ia_rdev, 0, xdata);
+                         makedev(ia_major(ia->ia_rdev), ia_minor(ia->ia_rdev)),
+                         0, xdata);
                 break;
         }
 
-- 
1.7.1