⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1.t

📁 早期freebsd实现
💻 T
📖 第 1 页 / 共 2 页
字号:
block device I/O function.When the mount is completed,.RN mfs_mountdoes not return as most other filesystem mount functions do;instead it sleeps in the kernel awaiting I/O requests.Each time an I/O request is posted for the filesystem,a wakeup is issued for the corresponding \fInewfs\fP process.When awakened, the process checks for requests on its buffer list.A read request is serviced by copying data from the section of the\fInewfs\fP address space corresponding to the requested disk blockto the kernel buffer.Similarly a write request is serviced by copying data to the section of the\fInewfs\fP address space corresponding to the requested disk blockfrom the kernel buffer.When all the requests have been serviced, the \fInewfs\fPprocess returns to sleep to await more requests..PPOnce mounted,all operations on files in the memory-based filesystem are handledby the \fIufs\fP filesystem code until they get to the point where thefilesystem needs to do I/O on the device.Here, the filesystem encounters the second piece of thememory-based filesystem.Instead of calling the special-device strategy routine,it calls the memory-based strategy routine,.RN mfs_strategy .Usually,the request is serviced by linking the buffer onto theI/O list for the memory-based filesystemvnode and sending a wakeup to the \fInewfs\fP process.This wakeup results in a context-switch to the \fInewfs\fPprocess, which does a copyin or copyout as described above.The strategy routine must be careful to check whetherthe I/O request is coming from the \fInewfs\fP process itself, however.Such requests happen during mount and unmount operations,when the kernel is reading and writing the superblock.Here,.RN mfs_strategymust do the I/O itself to avoid deadlock..PPThe final piece of kernel code to support thememory-based filesystem is the close routine.After the filesystem has been successfully unmounted,the device close routine is called.For a memory-based filesystem, the device close routine is.RN mfs_close .This routine flushes any pending I/O requests,then sets the I/O list head to a special valuethat is recognized by the I/O servicing loop in.RN mfs_mountas an indication that the filesystem is unmounted.The.RN mfs_mountroutine exits, in turn causing the \fInewfs\fP processto exit, resulting in the filesystem vanishing in a cloud of dirty pages..PPThe paging of the filesystem does not require any additionalcode beyond that already in the kernel to support virtual memory.The \fInewfs\fP process competes with other processes on an equal basisfor the machine's available memory.Data pages of the filesystem that have not yet been usedare zero-fill-on-demand pages that do not occupy memory,although they currently allocate space in backing store.As long as memory is plentiful, the entire contents of the filesystemremain memory resident.When memory runs short, the oldest pages of \fInewfs\fP will bepushed to backing store as part of the normal paging activity.The pages that are pushed usually hold the contents offiles that have been created in the memory-based filesystembut have not been recently accessed (or have been deleted)..[leffler.].SHPerformance.PPThe performance of the current memory-based filesystem is determined bythe memory-to-memory copy speed of the processor.Empirically we find that the throughput is about 45% of thismemory-to-memory copy speed.The basic set of steps for each block written is:.IP 1)memory-to-memory copy from the user process doing the write to a kernel buffer.IP 2)context-switch to the \fInewfs\fP process.IP 3)memory-to-memory copy from the kernel buffer to the \fInewfs\fP address space.IP 4)context switch back to the writing process.LPThus each write requires at least two memory-to-memory copiesaccounting for about 90% of the.SM CPUtime.The remaining 10% is consumed in the context switches andthe filesystem allocation and block location code.The actual context switch count is really only about halfof the worst case outlined above becauseread-ahead and write-behind allow multiple blocksto be handled with each context switch..PPOn the six-\c.SM "MIPS CCI"Power 6/32 machine,the raw reading and writing speed is only about twice that ofa regular disk-based filesystem.However, for processes that create and delete many files,the speedup is considerably greater.The reason for the speedup is that the filesystemmust do two synchronous operations to create a file,first writing the allocated inode to disk, then creating thedirectory entry.Deleting a file similarly requires at least two synchronousoperations.Here, the low latency of the memory-based filesystem isnoticeable compared to the disk-based filesystem,as a synchronous operation can be done withjust two context switches instead of incurring the disk latency..SHFuture Work.PPThe most obvious shortcoming of the current implementationis that filesystem blocks are copied twice, once between the \fInewfs\fPprocess' address space and the kernel buffer cache,and once between the kernel buffer and the requesting process.These copies are done in different process contexts, necessitatingtwo context switches per group of I/O requests.These problems arise because of the current inability of the kernelto do page-in operationsfor an address space other than that of the currently-running process,and the current inconvenience of mapping process-owned pages into the kernelbuffer cache.Both of these problems are expected to be solved in the next versionof the virtual memory system,and thus we chose not to address them in the current implementation.With the new version of the virtual memory system, we expect to useany part of physical memory as part of the buffer cache,even though it will not be entirely addressable at once within the kernel.In that system, the implementation of a memory-based filesystemthat avoids the double copy and context switches will be much easier..PPIdeally part of the kernel's address space would reside in pageable memory.Once such a facility is available it would be most efficient tobuild a memory-based filesystem within the kernel.One potential problem with such a scheme is that many kernelsare limited to a small address space (usually a few megabytes).This restriction limits the size of memory-basedfilesystem that such a machine can support.On such a machine, the kernel can describe a memory-based filesystemthat is larger than its address space and use a ``window''to map the larger filesystem address space into its limited address space.The window would maintain a cache of recently accessed pages.The problem with this scheme is that if the working set ofactive pages is greater than the size of the window, thenmuch time is spent remapping pages and invalidatingtranslation buffers.Alternatively, a separate address space could be constructed for eachmemory-based filesystem as in the current implementation,and the memory-resident pages of that address space could be mappedexactly as other cached pages are accessed..PPThe current system uses the existing local filesystem structuresand code to implement the memory-based filesystem.The major advantages of this approach are the sharing of codeand the simplicity of the approach.There are several disadvantages, however.One is that the size of the filesystem is fixed at mount time.This means that a fixed number of inodes (files) and data blockscan be supported.Currently, this approach requires enough swap space for the entirefilesystem, and prevents expansion and contraction of the filesystem on demand.The current design also prevents the filesystem from taking advantageof the memory-resident character of the filesystem.It would be interesting to explore other filesystem implementationsthat would be less expensive to execute and that would make betteruse of the space.For example, the current filesystem structure is optimized for magneticdisks.It includes replicated control structures, ``cylinder groups''with separate allocation maps and control structures,and data structures that optimize rotational layout of files.None of this is useful in a memory-based filesystem (at least when thebacking store for the filesystem is dynamically allocated and notcontiguous on a single disk type).On the other hand,directories could be implemented using dynamically-allocatedmemory organized as linked lists or trees rather than as files storedin ``disk'' blocks.Allocation and location of pages for file data might use virtual memoryprimitives and data structures rather than direct and indirect blocks.A reimplementation along these lines will be considered when the virtualmemory system in the current system has been replaced..[$LIST$.]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -