lkml.org 
[lkml]   [2011]   [Aug]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH] loop: add discard support for loop devices
    Date
    Lukas Czerner <lczerner@redhat.com> writes:

    >> @@ -484,6 +485,29 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio)
    >> }
    >> }
    >>
    >> + /*
    >> + * We use punch hole to reclaim the free space used by the
    >> + * image a.k.a. discard. However we do support discard if
    >> + * encryption is enabled, because it may give an attacker
    >> + * useful information.
    >> + */
    >> + if (bio->bi_rw & REQ_DISCARD) {
    >> + struct file *file = lo->lo_backing_file;
    >> + int mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
    >> +
    >> + if ((!file->f_op->fallocate) ||
    >> + lo->lo_encrypt_key_size) {
    >> + ret = -EOPNOTSUPP;
    >> + goto out;
    >> + }
    >> + ret = file->f_op->fallocate(file, mode, pos,
    >> + bio->bi_size);
    >> + if (unlikely(ret && ret != -EINVAL &&
    >> + ret != -EOPNOTSUPP))
    >> + ret = -EIO;
    >> + goto out;
    >> + }
    >> +

    Seems you missed the bizarre case of configuring a loop device over top
    of a block device.

    Cheers,
    Jeff


    \
     
     \ /
      Last update: 2011-08-18 17:35    [W:2.516 / U:0.200 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site