From: "Joseph D. Wagner" Subject: RE: Replicating directories - Intercepting write/modify system calls Date: Sat, 14 Feb 2004 07:08:56 -0600 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <000001c3f2fb$b4733cb0$0201a8c0@joe> References: Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT Return-path: Received: from ssa8.serverconfig.com ([209.51.129.179]:16106 "EHLO ssa8.serverconfig.com") by vger.kernel.org with ESMTP id S261974AbUBNNIz convert rfc822-to-8bit (ORCPT ); Sat, 14 Feb 2004 08:08:55 -0500 To: "'Siddhartha Jain'" , In-Reply-To: List-Id: linux-fsdevel.vger.kernel.org > Ok, to give an example (with ref to > http://www.faqs.org/docs/kernel_2_4/lki-3.html) > > the function open() really calls upon sys_open in fs/open.c. > > sys_open looks like: > asmlinkage long sys_open(const char __user * filename, int flags, int > mode) > { [trimmed] > } > > Change it to include: > 1. Check if the filename path matches any master definition in a config > file. > 2. If it does, append the (filename path - master path) and append the > remaining to the mirror path. > 3. Replicate every call within sys_open with the parameter mirror_file. > > Same goes for sys_write and other functions that modify a file (ioctl?). Ah! Right idea; wrong terminology. Sorry for the miscommunication. sys_open() is the kernel function that gets called when a user program calls the POSIX open() function. It could very well be considered part of the VFS because it does the pre-work before the file system specific function is called; however, most people, including myself, do not think of it that way. Assuming you decided to go forward with your project, this would be the correct location to start, but see my next point. >>>> Does it need to be a two-way synchronization, or is a one-way >>>> synchronization acceptable? In other words, do changes on the >>>> replica need to be synced back to the original? >>> For my purpose, one-way is fine. But two-way would be cool and >>> in the greater good of humankind ;) >> Is this for load balancing, or a sophisticated way of doing a backup? [paraphrased] For now, backup, but I'd like to do load balancing in the [paraphrased] future. If you want one-way, non-real-time duplication, you don't even need to hack the kernel. Simply create a daemon (program that runs in the background) that executes every x minutes to scan files for changes and duplicate those files. If you want two-way, non-real-time duplication for load balancing, simply run one daemon on each server: one on the original to send to the replica, and one on the replica to send to the original. The only catch is that you'd have no way of knowing if you're opening an outdated, unsynced file. To fix that, you'd need to hack the kernel. However, in this way you'd only have to change sys_open() and sys_close() with a minimal amount of changes to the kernel code leaving most of the work to the daemon. (Ah, and now we've scaled back your proposal to something more feasible.) This is the most likely solution to be accepted and adopted by the Linux community. If you want any real-time duplication, you've got your work cut out for you. Joseph D. Wagner