[cgl_discussion] Forced Unmount patch

Villalovos, John L john.l.villalovos at intel.com
Mon Oct 18 11:37:34 PDT 2004

Enclosed please find a patch for Forced Unmount.  This patch was
originally written by Monta Vista for the 2.4.x kernel.  It was then
ported to 2.6.8 by Atul Sabharwal at Intel Corporation.

This is Atul's patch.  I will be sending a clean up of the patch, that I
am working on, in the next couple of days.

-------------- next part --------------
Forced Unmount of a File System
By Atul Sabharwal
Forced Unmount as the name suggests gives an override to remove a file system
when a regular unmount operation would fail. It is a managed implementation for
"surprise removal" with no data loss. Currently, this can be achieved by
killing the applications which have open files, file maps, locks in the file
system. This brings us to the question as why do we need this feature. The
answer being that there are scenarios where the file maps, locks, files can be
released without having to kill the applications.  The applications can
gracefully recover from this operation by closing the file and polling for the
file system to get re-mounted.

Algorithm for Forced Unmount:
Forced unmount starts by marking the super block to be undergoing a forced
unmount operation. It then marks all the files open in the super block to be
undergoing a forced unmount.  These two operations prevent all system calls
except close to fail with an error –ENXIO. The typical operations are file
operations like read, write, seek, fcntl, ioctl etc. All file system lookup and
traversal operations also fail and return NULL. It then steps through the
address maps for the files and does an unmap operation thereby releasing the
page tables for the open files. Next, it removes the file locks and wakes up
all processes waiting on the lock. It also deletes the lock. After that, it
does a fput operation on the file.  After that, open files are cloned so that a
flush operation can be done on the cloned files. Once the cloned files are
closed, all data gets written to the storage media and the open files are
marked as detached. This is to note that we do a special close when the apps do
a close system call.  Also, the working directories of all processes inside the
forced unmounted file system are changed to NULL. The apps can recover from
this by doing the system call getcwd (). After that, a mntput operation is done
on the file system to bring the usage count to two.

Usage Scenarios:
Telecommunication devices like bladed system viz. ATCA need to hot swap blades
for reasons like blade overheat blade upgrade etc. On RAID systems, disks need
to be upgraded. For file system administration, file systems need to be
unmounted. For all these operations, a managed "surprise removal" is useful.

Advantages of Forced Unmount:
On hot plug enabled like ATCA systems, a user can pull a blade out without
having to reboot the system or kill applications. When the blade is plugged
back in, applications can proceed normally as before.  Also, on regular
systems, when a file system gets busy, the system administrator does not have
to reboot the system.  A forced unmount would suffice.

Disadvantages of Forced Unmount:
When a program has its binary in the forced unmounted file system, the
application would terminate with a segmentation fault as the code pages would
get removed from the virtual memory map. When the file system comes back alive,
these apps would have to be manually restarted.  Also, the root file system
cannot be force unmounted. Also, forced unmount works on a single file system
i.e. if there are child mounts inside a file system, forced unmount would fail.

File System Candidates for Forced Unmount:
On a typical UNIX system, /var, /tmp, /home, /opt would be good candidates to
perform a forced unmount operation.

Forced unmount is a useful feature for system administrators. It implements
"surprise removal" which requires minimal system administration as well as does
not require a system reboot. Also, if the applications are designed to continue
without their data files, they need not be terminated.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ForcedUnmount.pdf
Type: application/octet-stream
Size: 27934 bytes
Desc: ForcedUnmount.pdf
Url : http://lists.linux-foundation.org/pipermail/cgl_discussion/attachments/20041018/99fbc4cd/ForcedUnmount-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2.6.8.fumount.patch
Type: application/octet-stream
Size: 49754 bytes
Desc: 2.6.8.fumount.patch
Url : http://lists.linux-foundation.org/pipermail/cgl_discussion/attachments/20041018/99fbc4cd/2.6.8.fumount-0001.obj

More information about the cgl_discussion mailing list