Thread (20 messages) 20 messages, 7 authors, 2023-07-19

Re: [PATCH v2 4/4] brd: implement secure erase and write zeroes

From: Chaitanya Kulkarni <hidden>
Date: 2022-09-21 05:03:22
Also in: dm-devel

quoted hunk ↗ jump to hunk
  /*
@@ -300,23 +303,34 @@ out:
  
  void brd_do_discard(struct brd_device *brd, struct bio *bio)
  {
-	sector_t sector, len, front_pad;
+	bool zero_padding;
+	sector_t sector, len, front_pad, end_pad;
  
  	if (unlikely(!discard)) {
  		bio->bi_status = BLK_STS_NOTSUPP;
  		return;
  	}
  
+	zero_padding = bio_op(bio) == REQ_OP_SECURE_ERASE || bio_op(bio) == REQ_OP_WRITE_ZEROES;
  	sector = bio->bi_iter.bi_sector;
  	len = bio_sectors(bio);
  	front_pad = -sector & (PAGE_SECTORS - 1);
+
+	if (zero_padding && unlikely(front_pad != 0))
+		copy_to_brd(brd, page_address(ZERO_PAGE(0)), sector, min(len, front_pad) << SECTOR_SHIFT);
+
  	sector += front_pad;
  	if (unlikely(len <= front_pad))
  		return;
  	len -= front_pad;
-	len = round_down(len, PAGE_SECTORS);
+
+	end_pad = len & (PAGE_SECTORS - 1);
+	if (zero_padding && unlikely(end_pad != 0))
+		copy_to_brd(brd, page_address(ZERO_PAGE(0)), sector + len - end_pad, end_pad << SECTOR_SHIFT);
+	len -= end_pad;
+
Is it possible to avoid these long lines ?

-ck

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help