Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1323716 > unrolled thread

[PATCH v2 14/17] drivers:mtd:ubi:add backup operation in ubi_io_write

Started byBean Huo <jackyard88@gmail.com>
First post2016-02-02 03:40 +0100
Last post2016-02-02 04:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 14/17] drivers:mtd:ubi:add backup operation in ubi_io_write Bean Huo <jackyard88@gmail.com> - 2016-02-02 03:40 +0100
    Re: [PATCH v2 14/17] drivers:mtd:ubi:add backup operation in  ubi_io_write kbuild test robot <lkp@intel.com> - 2016-02-02 04:30 +0100

#1323716 — [PATCH v2 14/17] drivers:mtd:ubi:add backup operation in ubi_io_write

FromBean Huo <jackyard88@gmail.com>
Date2016-02-02 03:40 +0100
Subject[PATCH v2 14/17] drivers:mtd:ubi:add backup operation in ubi_io_write
Message-ID<qXz2O-3Wf-17@gated-at.bofh.it>
From: Bean Huo <beanhuo@micron.com>

This patch is to add backup lower page data codes in ubi_io_write.
If programming lower page, bakvol module will duplicate this lower page
data, then program to two different plane pages by multiple plane page program.

Signed-off-by: BeanHuo <beanhuo@micron.com>
---
 drivers/mtd/ubi/io.c | 73 +++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 61 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 5bbd1f0..6905929 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -222,6 +222,7 @@ retry:
  * @pnum: physical eraseblock number to write to
  * @offset: offset within the physical eraseblock where to write
  * @len: how many bytes to write
+ * @safeguard: if these data has to be duplicated to backup
  *
  * This function writes @len bytes of data from buffer @buf to offset @offset
  * of physical eraseblock @pnum. If all the data were successfully written,
@@ -233,11 +234,12 @@ retry:
  * to the flash media, but may be some garbage.
  */
 int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
-		 int len)
+		 int len, int safeguard)
 {
 	int err;
-	size_t written;
+	size_t retlen;
 	loff_t addr;
+	int skip;
 
 	dbg_io("write %d bytes to PEB %d:%d", len, pnum, offset);
 
@@ -281,14 +283,61 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
 	}
 
 	addr = (loff_t)pnum * ubi->peb_size + offset;
-	err = mtd_write(ubi->mtd, addr, len, &written, buf);
-	if (err) {
-		ubi_err(ubi, "error %d while writing %d bytes to PEB %d:%d, written %zd bytes",
-			err, len, pnum, offset, written);
-		dump_stack();
-		ubi_dump_flash(ubi, pnum, offset, len);
+#ifdef CONFIG_MTD_UBI_MLC_NAND_BAKVOL
+	skip = 0;
+	if (((offset == 0) && (len == ubi->peb_size)) ||
+		!safeguard)
+		skip = 1;
+
+	if (ubi_check_bakvol_module(ubi) && (!skip)) {
+		loff_t addr_temp;
+		unsigned char *buf_temp = (unsigned char *)buf;
+		int len_temp;
+		int writelen = 0;
+
+		addr_temp = addr;
+
+		for (len_temp = len; len_temp > 0; len_temp -= ubi->min_io_size,
+			addr_temp += ubi->min_io_size,
+			buf_temp += ubi->min_io_size) {
+			/* Split data according to min_io_size */
+
+			if (len_temp/ubi->min_io_size)
+				writelen = ubi->min_io_size;
+			else
+				writelen %= ubi->min_io_size;
+
+			if (is_backup_need(ubi, addr_temp)) {
+				err = ubi_duplicate_data_to_bakvol(ubi,
+					addr_temp, writelen, &retlen, buf_temp);
+				} else
+				err = mtd_write(ubi->mtd, addr_temp, writelen,
+						&retlen, buf_temp);
+
+			if (err) {
+				ubi_err(ubi, "Writing %d byptes to PEB %d:%d",
+					writelen, pnum, offset);
+				ubi_err(ubi, "Error %d", err);
+				ubi_err(ubi, "Written %d bytes", retlen);
+				dump_stack();
+				ubi_dump_flash(ubi, pnum, offset, writelen);
+				} else
+				ubi_assert(retlen == writelen);
+		}
 	} else
-		ubi_assert(written == len);
+#endif
+	{
+		err = mtd_write(ubi->mtd, addr, len, &retlen, buf);
+		if (err) {
+			ubi_err(ubi, "Writing %d byptes to PEB %d:%d",
+				len, pnum, offset);
+			ubi_err(ubi, "Error %d", err);
+			ubi_err(ubi, "Written %zd bytes", retlen);
+			dump_stack();
+			ubi_dump_flash(ubi, pnum, offset, len);
+		} else
+			ubi_assert(retlen == len);
+	}
 
 	if (!err) {
 		err = self_check_write(ubi, buf, pnum, offset, len);
@@ -438,7 +487,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
 
 		/* Write a pattern and check it */
 		memset(ubi->peb_buf, patterns[i], ubi->peb_size);
-		err = ubi_io_write(ubi, ubi->peb_buf, pnum, 0, ubi->peb_size);
+		err = ubi_io_write(ubi, ubi->peb_buf, pnum, 0, ubi->peb_size, 0);
 		if (err)
 			goto out;
 
@@ -862,7 +911,7 @@ int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum,
 	if (ubi_dbg_power_cut(ubi, POWER_CUT_EC_WRITE))
 		return -EROFS;
 
-	err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize);
+	err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize, 0);
 	return err;
 }
 
@@ -1114,7 +1163,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
 
 	p = (char *)vid_hdr - ubi->vid_hdr_shift;
 	err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset,
-			   ubi->vid_hdr_alsize);
+			   ubi->vid_hdr_alsize, 0);
 	return err;
 }
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1323762 — Re: [PATCH v2 14/17] drivers:mtd:ubi:add backup operation in ubi_io_write

Fromkbuild test robot <lkp@intel.com>
Date2016-02-02 04:30 +0100
SubjectRe: [PATCH v2 14/17] drivers:mtd:ubi:add backup operation in ubi_io_write
Message-ID<qXzPb-4CF-5@gated-at.bofh.it>
In reply to#1323716

[Multipart message — attachments visible in raw view] — view raw

Hi Bean,

[auto build test WARNING on v4.5-rc2]
[also build test WARNING on next-20160201]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Bean-Huo/Add-a-bakvol-module-in-UBI-layer-for-MLC-paired-page-power-loss-issue/20160202-104450
config: x86_64-randconfig-x012-201605 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/mtd/ubi/io.c: In function 'ubi_io_write':
>> drivers/mtd/ubi/io.c:242:6: warning: unused variable 'skip' [-Wunused-variable]
     int skip;
         ^

vim +/skip +242 drivers/mtd/ubi/io.c

   226	 *
   227	 * This function writes @len bytes of data from buffer @buf to offset @offset
   228	 * of physical eraseblock @pnum. If all the data were successfully written,
   229	 * zero is returned. If an error occurred, this function returns a negative
   230	 * error code. If %-EIO is returned, the physical eraseblock most probably went
   231	 * bad.
   232	 *
   233	 * Note, in case of an error, it is possible that something was still written
   234	 * to the flash media, but may be some garbage.
   235	 */
   236	int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
   237			 int len, int safeguard)
   238	{
   239		int err;
   240		size_t retlen;
   241		loff_t addr;
 > 242		int skip;
   243	
   244		dbg_io("write %d bytes to PEB %d:%d", len, pnum, offset);
   245	
   246		ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
   247		ubi_assert(offset >= 0 && offset + len <= ubi->peb_size);
   248		ubi_assert(offset % ubi->hdrs_min_io_size == 0);
   249		ubi_assert(len > 0 && len % ubi->hdrs_min_io_size == 0);
   250	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web