Whamcloud - gitweb
b=15428
authorjxiong <jxiong>
Thu, 12 Feb 2009 04:24:10 +0000 (04:24 +0000)
committerjxiong <jxiong>
Thu, 12 Feb 2009 04:24:10 +0000 (04:24 +0000)
r=adilger

Fix a crash issue for raid5 zerocopy patch.

lustre/kernel_patches/patches/raid5-zerocopy-rhel5.patch

index dd80825..31b825e 100644 (file)
@@ -1,15 +1,17 @@
-diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/raid5.c
---- linux-2.6.18-53.orig/drivers/md/raid5.c    2007-12-28 19:09:20.000000000 +0800
-+++ linux-2.6.18-53/drivers/md/raid5.c 2007-12-28 19:09:32.000000000 +0800
-@@ -633,6 +633,7 @@ static int raid5_end_read_request(struct
+diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/drivers/md/raid5.c
+--- linux-2.6.18-92.1.22.orig/drivers/md/raid5.c       2009-02-10 13:47:54.000000000 +0800
++++ linux-2.6.18-92.1.22/drivers/md/raid5.c    2009-02-10 14:44:24.000000000 +0800
+@@ -633,6 +633,9 @@ static int raid5_end_read_request(struct
                clear_buffer_uptodate(bh);
        }
  #endif
-+      BUG_ON(test_bit(R5_Direct, &sh->dev[i].flags));
++      /* Read on a Directing write is allowable */
++      /* BUG_ON(test_bit(R5_Direct, &sh->dev[i].flags)) */
++      BUG_ON(sh->dev[i].req.bi_io_vec[0].bv_page != sh->dev[i].page);
        clear_bit(R5_LOCKED, &sh->dev[i].flags);
        set_bit(STRIPE_HANDLE, &sh->state);
        release_stripe(sh);
-@@ -671,6 +672,10 @@ static int raid5_end_write_request (stru
+@@ -671,6 +674,10 @@ static int raid5_end_write_request (stru
  
        rdev_dec_pending(conf->disks[i].rdev, conf->mddev);
        
@@ -20,7 +22,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
        clear_bit(R5_LOCKED, &sh->dev[i].flags);
        set_bit(STRIPE_HANDLE, &sh->state);
        __release_stripe(conf, sh);
-@@ -911,7 +916,27 @@ static sector_t compute_blocknr(struct s
+@@ -911,7 +918,27 @@ static sector_t compute_blocknr(struct s
        return r_sector;
  }
  
@@ -48,7 +50,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
  
  /*
   * Copy data between a page in the stripe cache, and one or more bion
-@@ -1003,8 +1028,9 @@ static void compute_parity5(struct strip
+@@ -1003,8 +1030,9 @@ static void compute_parity5(struct strip
  {
        raid5_conf_t *conf = sh->raid_conf;
        int i, pd_idx = sh->pd_idx, disks = sh->disks, count;
@@ -59,7 +61,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
  
        PRINTK("compute_parity5, stripe %llu, method %d\n",
                (unsigned long long)sh->sector, method);
-@@ -1054,34 +1080,90 @@ static void compute_parity5(struct strip
+@@ -1054,34 +1082,92 @@ static void compute_parity5(struct strip
                count = 1;
        }
        
@@ -90,6 +92,8 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
 +                      page = zero_copy_data(wbi, sector);
 +                      if (page) {
 +                              atomic_inc(&conf->writes_zcopy);
++                              /* The pointer must be restored whenever the LOCKED
++                               * gets cleared. */
 +                              dev->req.bi_io_vec[0].bv_page = page;
 +                              set_bit(R5_Direct, &dev->flags);
 +                              clear_bit(R5_UPTODATE, &sh->dev[i].flags);
@@ -167,7 +171,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
        }
        if (count != 1)
                xor_block(count, STRIPE_SIZE, ptr);
-@@ -1098,6 +1180,7 @@ static void compute_parity6(struct strip
+@@ -1098,6 +1184,7 @@ static void compute_parity6(struct strip
        raid6_conf_t *conf = sh->raid_conf;
        int i, pd_idx = sh->pd_idx, qd_idx, d0_idx, disks = conf->raid_disks, count;
        struct bio *chosen;
@@ -175,7 +179,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
        /**** FIX THIS: This could be very bad if disks is close to 256 ****/
        void *ptrs[disks];
  
-@@ -1127,18 +1210,47 @@ static void compute_parity6(struct strip
+@@ -1127,18 +1214,49 @@ static void compute_parity6(struct strip
                BUG();          /* Not implemented yet */
        }
  
@@ -211,6 +215,8 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
 +                       * algorithm. -jay */
 +                      if (page && !PageHighMem(page)) {
 +                              atomic_inc(&conf->writes_zcopy);
++                              /* The pointer must be restored whenever the LOCKED
++                               * gets cleared. */
 +                              sh->dev[i].req.bi_io_vec[0].bv_page = page;
 +                              set_bit(R5_Direct, &sh->dev[i].flags);
 +                              clear_bit(R5_UPTODATE, &sh->dev[i].flags);
@@ -232,7 +238,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
  
  //    switch(method) {
  //    case RECONSTRUCT_WRITE:
-@@ -1149,8 +1261,12 @@ static void compute_parity6(struct strip
+@@ -1149,8 +1267,12 @@ static void compute_parity6(struct strip
                count = 0;
                i = d0_idx;
                do {
@@ -247,7 +253,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
                                printk("block %d/%d not uptodate on parity calc\n", i,count);
                        i = raid6_next_disk(i, disks);
                } while ( i != d0_idx );
-@@ -1597,7 +1713,8 @@ static void handle_stripe5(struct stripe
+@@ -1599,7 +1721,8 @@ static void handle_stripe5(struct stripe
                if (sh->dev[i].written) {
                    dev = &sh->dev[i];
                    if (!test_bit(R5_LOCKED, &dev->flags) &&
@@ -257,7 +263,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
                        /* We can return any write requests */
                            struct bio *wbi, *wbi2;
                            int bitmap_end = 0;
-@@ -1605,6 +1722,7 @@ static void handle_stripe5(struct stripe
+@@ -1607,6 +1730,7 @@ static void handle_stripe5(struct stripe
                            spin_lock_irq(&conf->device_lock);
                            wbi = dev->written;
                            dev->written = NULL;
@@ -265,7 +271,23 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
                            while (wbi && wbi->bi_sector < dev->sector + STRIPE_SECTORS) {
                                    wbi2 = r5_next_bio(wbi, dev->sector);
                                    if (--wbi->bi_phys_segments == 0) {
-@@ -2173,7 +2291,8 @@ static void handle_stripe6(struct stripe
+@@ -1970,6 +2094,15 @@ static void handle_stripe5(struct stripe
+                               set_bit(STRIPE_DEGRADED, &sh->state);
+                       PRINTK("skip op %ld on disc %d for sector %llu\n",
+                               bi->bi_rw, i, (unsigned long long)sh->sector);
++
++                      if (test_bit(R5_Direct, &sh->dev[i].flags)) {
++                              /* restore the page pointer of req, otherwise,
++                               * no any read is permitted on this stripe, this is
++                               * not what we want. -jay */
++                              BUG_ON(sh->dev[i].req.bi_io_vec[0].bv_page == sh->dev[i].page);
++                              sh->dev[i].req.bi_io_vec[0].bv_page = sh->dev[i].page;
++                      }
++
+                       clear_bit(R5_LOCKED, &sh->dev[i].flags);
+                       set_bit(STRIPE_HANDLE, &sh->state);
+               }
+@@ -2175,7 +2308,8 @@ static void handle_stripe6(struct stripe
                        if (sh->dev[i].written) {
                                dev = &sh->dev[i];
                                if (!test_bit(R5_LOCKED, &dev->flags) &&
@@ -275,7 +297,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
                                        /* We can return any write requests */
                                        int bitmap_end = 0;
                                        struct bio *wbi, *wbi2;
-@@ -2182,6 +2301,7 @@ static void handle_stripe6(struct stripe
+@@ -2184,6 +2318,7 @@ static void handle_stripe6(struct stripe
                                        spin_lock_irq(&conf->device_lock);
                                        wbi = dev->written;
                                        dev->written = NULL;
@@ -283,7 +305,23 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
                                        while (wbi && wbi->bi_sector < dev->sector + STRIPE_SECTORS) {
                                                wbi2 = r5_next_bio(wbi, dev->sector);
                                                if (--wbi->bi_phys_segments == 0) {
-@@ -3450,6 +3570,9 @@ static int run(mddev_t *mddev)
+@@ -2535,6 +2670,15 @@ static void handle_stripe6(struct stripe
+                               set_bit(STRIPE_DEGRADED, &sh->state);
+                       PRINTK("skip op %ld on disc %d for sector %llu\n",
+                               bi->bi_rw, i, (unsigned long long)sh->sector);
++
++                      if (test_bit(R5_Direct, &sh->dev[i].flags)) {
++                              /* restore the page pointer of req, otherwise,
++                               * no any read is permitted on this stripe, this is
++                               * not what we want. -jay */
++                              BUG_ON(sh->dev[i].req.bi_io_vec[0].bv_page == sh->dev[i].page);
++                              sh->dev[i].req.bi_io_vec[0].bv_page = sh->dev[i].page;
++                      }
++
+                       clear_bit(R5_LOCKED, &sh->dev[i].flags);
+                       set_bit(STRIPE_HANDLE, &sh->state);
+               }
+@@ -3456,6 +3600,9 @@ static int run(mddev_t *mddev)
        mddev->queue->max_phys_segments = conf->chunk_size * conf->previous_raid_disks >> PAGE_SHIFT;
        mddev->queue->max_hw_segments = conf->chunk_size * conf->previous_raid_disks >> PAGE_SHIFT;;
  
@@ -293,7 +331,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
        return 0;
  abort:
        if (conf) {
-@@ -3536,9 +3659,11 @@ static void status (struct seq_file *seq
+@@ -3542,9 +3689,11 @@ static void status (struct seq_file *seq
                        atomic_read(&conf->handled_in_raid5d),
                        atomic_read(&conf->out_of_stripes),
                        atomic_read(&conf->handle_called));
@@ -307,9 +345,9 @@ diff -pur linux-2.6.18-53.orig/drivers/md/raid5.c linux-2.6.18-53/drivers/md/rai
        seq_printf (seq, "\n\t\t%u delayed, %u bit delayed, %u active, queues: %u in, %u out\n",
                        atomic_read(&conf->delayed), atomic_read(&conf->bit_delayed),
                        atomic_read(&conf->active_stripes),
-diff -pur linux-2.6.18-53.orig/include/linux/backing-dev.h linux-2.6.18-53/include/linux/backing-dev.h
---- linux-2.6.18-53.orig/include/linux/backing-dev.h   2007-12-28 14:49:26.000000000 +0800
-+++ linux-2.6.18-53/include/linux/backing-dev.h        2007-12-28 19:09:32.000000000 +0800
+diff -pur linux-2.6.18-92.1.22.orig/include/linux/backing-dev.h linux-2.6.18-92.1.22/include/linux/backing-dev.h
+--- linux-2.6.18-92.1.22.orig/include/linux/backing-dev.h      2009-02-10 13:47:54.000000000 +0800
++++ linux-2.6.18-92.1.22/include/linux/backing-dev.h   2009-02-10 14:44:14.000000000 +0800
 @@ -48,6 +48,7 @@ struct backing_dev_info {
  #define BDI_CAP_READ_MAP      0x00000010      /* Can be mapped for reading */
  #define BDI_CAP_WRITE_MAP     0x00000020      /* Can be mapped for writing */
@@ -337,9 +375,9 @@ diff -pur linux-2.6.18-53.orig/include/linux/backing-dev.h linux-2.6.18-53/inclu
 +
  
  #endif                /* _LINUX_BACKING_DEV_H */
-diff -pur linux-2.6.18-53.orig/include/linux/page-flags.h linux-2.6.18-53/include/linux/page-flags.h
---- linux-2.6.18-53.orig/include/linux/page-flags.h    2007-12-28 14:49:26.000000000 +0800
-+++ linux-2.6.18-53/include/linux/page-flags.h 2007-12-28 19:09:32.000000000 +0800
+diff -pur linux-2.6.18-92.1.22.orig/include/linux/page-flags.h linux-2.6.18-92.1.22/include/linux/page-flags.h
+--- linux-2.6.18-92.1.22.orig/include/linux/page-flags.h       2009-02-10 13:47:54.000000000 +0800
++++ linux-2.6.18-92.1.22/include/linux/page-flags.h    2009-02-10 14:44:14.000000000 +0800
 @@ -86,6 +86,7 @@
  #define PG_reclaim            17      /* To be reclaimed asap */
  #define PG_nosave_free                18      /* Free, should not be written */
@@ -348,7 +386,7 @@ diff -pur linux-2.6.18-53.orig/include/linux/page-flags.h linux-2.6.18-53/includ
  #define PG_xpmem              27      /* Testing for xpmem. */
  
  /* PG_owner_priv_1 users should have descriptive aliases */
-@@ -252,6 +253,14 @@
+@@ -283,6 +284,14 @@
  
  struct page;  /* forward declaration */
  
@@ -363,9 +401,9 @@ diff -pur linux-2.6.18-53.orig/include/linux/page-flags.h linux-2.6.18-53/includ
  int test_clear_page_dirty(struct page *page);
  int test_clear_page_writeback(struct page *page);
  int test_set_page_writeback(struct page *page);
-diff -pur linux-2.6.18-53.orig/include/linux/raid/raid5.h linux-2.6.18-53/include/linux/raid/raid5.h
---- linux-2.6.18-53.orig/include/linux/raid/raid5.h    2007-12-28 18:55:24.000000000 +0800
-+++ linux-2.6.18-53/include/linux/raid/raid5.h 2007-12-28 19:09:32.000000000 +0800
+diff -pur linux-2.6.18-92.1.22.orig/include/linux/raid/raid5.h linux-2.6.18-92.1.22/include/linux/raid/raid5.h
+--- linux-2.6.18-92.1.22.orig/include/linux/raid/raid5.h       2009-02-10 13:47:54.000000000 +0800
++++ linux-2.6.18-92.1.22/include/linux/raid/raid5.h    2009-02-10 14:44:14.000000000 +0800
 @@ -156,8 +156,9 @@ struct stripe_head {
  #define       R5_Overlap      7       /* There is a pending overlapping request on this block */
  #define       R5_ReadError    8       /* seen a read error here recently */
@@ -377,9 +415,9 @@ diff -pur linux-2.6.18-53.orig/include/linux/raid/raid5.h linux-2.6.18-53/includ
  /*
   * Write method
   */
-diff -pur linux-2.6.18-53.orig/mm/filemap.c linux-2.6.18-53/mm/filemap.c
---- linux-2.6.18-53.orig/mm/filemap.c  2007-12-28 14:49:26.000000000 +0800
-+++ linux-2.6.18-53/mm/filemap.c       2007-12-28 19:09:32.000000000 +0800
+diff -pur linux-2.6.18-92.1.22.orig/mm/filemap.c linux-2.6.18-92.1.22/mm/filemap.c
+--- linux-2.6.18-92.1.22.orig/mm/filemap.c     2009-02-10 13:47:54.000000000 +0800
++++ linux-2.6.18-92.1.22/mm/filemap.c  2009-02-10 14:44:14.000000000 +0800
 @@ -30,6 +30,7 @@
  #include <linux/security.h>
  #include <linux/syscalls.h>