<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Greetings All,<br>
<br>
IMPORTANT: Do not try this on a live system with data that you care about.&nbsp; The following is not documented or supported in any way, and only barely tested.&nbsp; You have been warned!<br>
<br>
Now that I have your attention, what I am referring to is a method to use &quot;hidden&quot; mounts on a server to get a &quot;live&quot; posix interface to a lustre target, without using LVM or hardware-based snapshots.&nbsp; I have only experimented with an MDT using ldiskfs; ZFS
 may have ways of making this safer and easier, or it might not work at all.&nbsp; While a Lustre MDT is running, we can use bind and remount tricks to see it as ldiskfs *and* get it into a read-only mode.<br>
<br>
I'm posting this just in case it fills an emergency need that someone has.&nbsp; Or, if you are feeling adventurous and want to experiment and report back that would be great.&nbsp; Maybe this actually works well and allows for cool new use cases and can become a intentional
 and documented feature in the future!<br>
<br>
As I mentioned, this is not a supported feature of Lustre.&nbsp; I believe it might conceivably be so useful for backing up the MDT, performing fast filesystem analysis, setting up lightweight event triggers, debugging, etc... that I think it *could* be worth trying
 to enhance and make it supportable in the future.&nbsp; If anyone wants to play with it, or has a student in need of a research project, well... here you go.&nbsp; An example showing the procedure I came up with, along with a few more technical details, are included
 below.<br>
<br>
Thanks and happy hacking,<br>
Nathan<br>
<br>
<br>
=== Test Procedure ===<br>
<br>
* Setup:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # mkdir /mnt/.hidden_mdt<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # mkdir /mnt/live-mirror<br>
<br>
* Then on to the sketchy stuff:<br>
&nbsp; (The &quot;lfstest--vg-mdttest&quot; device is already a running MDT with active clients.)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # mount -t ldiskfs /dev/mapper/lfstest--vg-mdttest /mnt/.hidden_mdt<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # mount --bind /mnt/.hidden_mdt /mnt/live-mirror<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # mount -o remount,ro /mnt/live-mirror<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # umount /mnt/.hidden_mdt<br>
<br>
* Now we have a read-only mount to access the MDT:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # mount | grep mdt<br>
&nbsp;&nbsp;&nbsp; /dev/mapper/lfstest--vg-mdttest on /mnt/lustre/lfstest-mdt type lustre (rw,noauto,acl,errors=panic,user_xattr)<br>
&nbsp;&nbsp;&nbsp; /mnt/.hidden_mdt on /mnt/live-mirror type none (ro,bind)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # echo &quot;this should not work&quot; &gt; /mnt/live-mirror/ROOT/test<br>
&nbsp;&nbsp;&nbsp; -bash: /mnt/live-mirror/ROOT/test: Read-only file system<br>
<br>
* Client changes show up immediately:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # ssh client1 'echo &quot;ASDF&quot; &gt; /mnt/lustre/client/test2'<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # ls -l /mnt/live-mirror/ROOT/test2<br>
&nbsp;&nbsp;&nbsp; -rw-r--r-- 1 root root 0 May&nbsp; 7 14:51 /mnt/live-mirror/ROOT/test2<br>
<br>
&nbsp; Note that instant updates to all metadata are probably not guaranteed, due to cache coherency of multiple threads.<br>
<br>
* And we can read all the Extended Attributes, such as with:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # getfattr -d -m &quot;.*&quot; -e hex /mnt/live-mirror/ROOT/test2<br>
<br>
* Run any system check, backup, or analysis processes as desired...<br>
<br>
* Cleanup:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # sync<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # umount /mnt/live-mirror<br>
<br>
<br>
=== Analysis with System Tap ===<br>
<br>
* In a separate window, watch for journal activity with:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # stap -e 'probe module(&quot;ldiskfs&quot;).function(&quot;*journal*&quot;) { printf(&quot;%d %s %s\n&quot;, tid(), execname(), probefunc()) }'<br>
<br>
&nbsp; Testing of a simpler read-only remount made several journal calls, even with &quot;noload&quot;.&nbsp; That is why the extra bind mounts are required; they appeared to make no journal calls, showing that they are safer.<br>
<br>
&nbsp; Note that in the very last &quot;umount&quot; step of the test procedure I did actually see journal events in system tap.&nbsp; However, none were for the &quot;umount&quot; process, so I believe they were just buffered from the client write, holdovers from sync, or periodic housekeeping.&nbsp;
 Repeating the whole process without any client writes resulted in no system tap events at all, as expected.<br>
<br>
* In a separate window, look for all function calls from the ldiskfs module:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # stap -e 'probe module(&quot;ldiskfs&quot;).function(&quot;*&quot;) { printf(&quot;%d %s %s\n&quot;, tid(), execname(), probefunc()) }'<br>
<br>
&nbsp; Testing showed that the total set of calls made through the &quot;sketchy stuff&quot; is:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10354 mount ldiskfs_get_sb<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10356 mount ldiskfs_release_dir<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10356 mount ldiskfs_release_dir<br>
<br>
<br>
=== Additional Notes ===<br>
<br>
In essence what this is doing is using the same superblock, inodes, etc. for the ldiskfs mount as the running Lustre filesystem.&nbsp; Internally, Lustre mounts the MDT as ldiskfs, and as long as the second mount uses the same filesystem type, then the kernel doesn't
 really mount the device again, it just creates a second reference to the superblock.&nbsp; The extra steps to make it a read-only mount are simply there to reduce the risk of corrupting the filesystem by accidental modification using the wrong mountpoint.<br>
<br>
Be warned that other approaches that might bypass the kernel checks for multiple mounts of the same block device are more dangerous than this approach, since even a &quot;read-only&quot; mount of the device will still have side-effects like recovering the journal (while
 the filesystem is already in use by Lustre) that could seriously corrupt the filesystem!<br>
<br>
The bigest risk areas for the use of the &quot;live&quot; ldiskfs and bind mounts are in areas where Lustre is accessing the ldiskfs on-disk structures or in-memory cached items in a manner *differently* from the VFS.&nbsp; There is a chance that this may cause in-memory
 inconsistencies, crashes, or potentially data corruption.&nbsp; I have been warned of problems during shutdown if the ldiskfs mountpoint is still mounted when Lustre stops but have not yet tested that.<br>
<br>
</div>
</body>
</html>