@@ -363,6 +363,8 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
363
363
}
364
364
if (nbd -> config -> flags & NBD_FLAG_ROTATIONAL )
365
365
lim .features |= BLK_FEAT_ROTATIONAL ;
366
+ if (nbd -> config -> flags & NBD_FLAG_SEND_WRITE_ZEROES )
367
+ lim .max_write_zeroes_sectors = UINT_MAX >> SECTOR_SHIFT ;
366
368
367
369
lim .logical_block_size = blksize ;
368
370
lim .physical_block_size = blksize ;
@@ -432,6 +434,8 @@ static u32 req_to_nbd_cmd_type(struct request *req)
432
434
return NBD_CMD_WRITE ;
433
435
case REQ_OP_READ :
434
436
return NBD_CMD_READ ;
437
+ case REQ_OP_WRITE_ZEROES :
438
+ return NBD_CMD_WRITE_ZEROES ;
435
439
default :
436
440
return U32_MAX ;
437
441
}
@@ -648,6 +652,8 @@ static blk_status_t nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd,
648
652
649
653
if (req -> cmd_flags & REQ_FUA )
650
654
nbd_cmd_flags |= NBD_CMD_FLAG_FUA ;
655
+ if ((req -> cmd_flags & REQ_NOUNMAP ) && (type == NBD_CMD_WRITE_ZEROES ))
656
+ nbd_cmd_flags |= NBD_CMD_FLAG_NO_HOLE ;
651
657
652
658
/* We did a partial send previously, and we at least sent the whole
653
659
* request struct, so just go and send the rest of the pages in the
@@ -1717,6 +1723,8 @@ static int nbd_dbg_flags_show(struct seq_file *s, void *unused)
1717
1723
seq_puts (s , "NBD_FLAG_SEND_FUA\n" );
1718
1724
if (flags & NBD_FLAG_SEND_TRIM )
1719
1725
seq_puts (s , "NBD_FLAG_SEND_TRIM\n" );
1726
+ if (flags & NBD_FLAG_SEND_WRITE_ZEROES )
1727
+ seq_puts (s , "NBD_FLAG_SEND_WRITE_ZEROES\n" );
1720
1728
1721
1729
return 0 ;
1722
1730
}
0 commit comments