enhacement to mdmfs

From: Michal Mertl (mime_at_traveller.cz)
Date: 11/30/04

  • Next message: Joseph Koshy: "Dual CPU detection problem"
    Date: Tue, 30 Nov 2004 12:21:35 +0100
    To: freebsd-current@freebsd.org
    
    
    

    Hello,

    I've recently shot my foot with mdmfs. Of course it was a pilot error but
    the funcioanility I was looking for might be usefull.

    I want to mount vnode-backed md(4) on boot without formatting it (e.g. for a
    jail). Is it possible with current boot scripts?

    I wrote a simple patch to mdmfs so such md disk can be put in /etc/fstab. It
    adds '-K' option do mdmfs(8) to Keep contents. The line to attach such disk
    in fstab looks like this:

    md /jail mfs rw,-K,-F=/var/jailfile 0 0

    Comments welcome. If people find it usefull I'd like to have it commited. I
    can fill the PR with enhancement request.

    Patch attached.

    -- 
    Michal Mertl
    
    

    Index: mdmfs.8
    ===================================================================
    RCS file: /home/fcvs/cvs/src/sbin/mdmfs/mdmfs.8,v
    retrieving revision 1.20
    diff -u -3 -r1.20 mdmfs.8
    --- mdmfs.8 17 May 2004 08:35:41 -0000 1.20
    +++ mdmfs.8 30 Nov 2004 10:56:22 -0000
    @@ -36,7 +36,7 @@
     driver
     .Sh SYNOPSIS
     .Nm
    -.Op Fl DLlMNSUX
    +.Op Fl DKLlMNSUX
     .Op Fl a Ar maxcontig
     .Op Fl b Ar block-size
     .Op Fl c Ar cylinders
    @@ -57,7 +57,7 @@
     .Ar mount-point
     .Nm
     .Fl C
    -.Op Fl lNU
    +.Op Fl KlNU
     .Op Fl a Ar maxcontig
     .Op Fl b Ar block-size
     .Op Fl c Ar cylinders
    @@ -162,6 +162,12 @@
     The fragment size of the file system in bytes.
     .It Fl i Ar bytes
     Number of bytes per inode.
    +.It Fl K
    +Preserve contents of vnode-backed
    +.Pq Dv MD_VNODE
    +memory disk.
    +Must be used in conjunction with
    +.Fl F .
     .It Fl l
     Enable multilabel MAC on the new file system.
     .It Fl L
    Index: mdmfs.c
    ===================================================================
    RCS file: /home/fcvs/cvs/src/sbin/mdmfs/mdmfs.c,v
    retrieving revision 1.20
    diff -u -3 -r1.20 mdmfs.c
    --- mdmfs.c 17 May 2004 07:07:20 -0000 1.20
    +++ mdmfs.c 30 Nov 2004 10:51:56 -0000
    @@ -89,7 +89,7 @@
                 *mount_arg;
             enum md_types mdtype; /* The type of our memory disk. */
             bool have_mdtype;
    - bool detach, softdep, autounit;
    + bool detach, softdep, autounit, keepdata;
             char *mtpoint, *unitstr;
             char *p;
             int ch;
    @@ -119,7 +119,7 @@
                     compat = true;
     
             while ((ch = getopt(argc, argv,
    - "a:b:Cc:Dd:e:F:f:hi:LlMm:Nn:O:o:p:Ss:t:Uv:w:X")) != -1)
    + "a:b:Cc:Dd:e:F:f:hi:KLlMm:Nn:O:o:p:Ss:t:Uv:w:X")) != -1)
                     switch (ch) {
                     case 'a':
                             argappend(&newfs_arg, "-a %s", optarg);
    @@ -167,6 +167,8 @@
                                     usage();
                             loudsubs = true;
                             break;
    + case 'K':
    + keepdata = true;
                     case 'l':
                             argappend(&newfs_arg, "-l");
                             break;
    @@ -233,7 +235,6 @@
             argv += optind;
             if (argc < 2)
                     usage();
    -
             /* Make compatibility assumptions. */
             if (compat) {
                     mi.mi_mode = 01777;
    @@ -258,6 +259,11 @@
             mtpoint = argv[1];
             if (!have_mdtype)
                     mdtype = MD_SWAP;
    +
    + /* If we want to use vnode backed file and don't newfs it */
    + if (keepdata && mdtype != MD_VNODE)
    + err(1, "Must specify -F with -K");
    +
             if (softdep)
                     argappend(&newfs_arg, "-U");
     
    @@ -268,7 +274,8 @@
                     do_mdconfig_attach_au(mdconfig_arg, mdtype);
             else
                     do_mdconfig_attach(mdconfig_arg, mdtype);
    - do_newfs(newfs_arg);
    + if (!keepdata)
    + do_newfs(newfs_arg);
             do_mount(mount_arg, mtpoint);
             do_mtptsetup(mtpoint, &mi);
     
    @@ -665,13 +672,13 @@
                     name = "mdmfs";
             if (!compat)
                     fprintf(stderr,
    -"usage: %s [-DLlMNSUX] [-a maxcontig [-b block-size] [-c cylinders]\n"
    +"usage: %s [-DKLlMNSUX] [-a maxcontig [-b block-size] [-c cylinders]\n"
     "\t[-d rotdelay] [-e maxbpg] [-F file] [-f frag-size] [-i bytes]\n"
     "\t[-m percent-free] [-n rotational-positions] [-O optimization]\n"
     "\t[-o mount-options] [-p permissions] [-s size] [-w user:group]\n"
     "\tmd-device mount-point\n", name);
             fprintf(stderr,
    -"usage: %s -C [-lNU] [-a maxcontig] [-b block-size] [-c cylinders]\n"
    +"usage: %s -C [-lKNU] [-a maxcontig] [-b block-size] [-c cylinders]\n"
     "\t[-d rotdelay] [-e maxbpg] [-F file] [-f frag-size] [-i bytes]\n"
     "\t[-m percent-free] [-n rotational-positions] [-O optimization]\n"
     "\t[-o mount-options] [-s size] md-device mount-point\n", name);

    
    

    _______________________________________________
    freebsd-current@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-current
    To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"


  • Next message: Joseph Koshy: "Dual CPU detection problem"

    Relevant Pages

    • Re: [PATCH] sendfile removal
      ... As I said, this new non blocking feature on the input side (disk), is ... nice and usefull. ... (For people scared by splice() ...
      (Linux-Kernel)
    • Re: new DDK sample code ideas
      ... what i would find usefull is a RAMDISK driver that ... supports larger than 64 MB disk size. ... Bruno. ...
      (microsoft.public.development.device.drivers)
    • Re: enhacement to mdmfs
      ... >>I've recently shot my foot with mdmfs. ... Of course it was a pilot error but ... >>the funcioanility I was looking for might be usefull. ... If people find it usefull I'd like to have it commited. ...
      (freebsd-current)
    • Re: disk space decrease at rapid rate
      ... i found it so usefull to dislay size distribution of a disk. ...
      (microsoft.public.windows.server.sbs)