From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Dilger Subject: Re: [RFC PATCH] Filesystem Journal Notifications Date: Sun, 14 Sep 2008 19:31:26 -0700 Message-ID: <20080915023126.GF4090@webber.adilger.int> References: <20080912220649.GB26999@apaithan-desktop.sanmateo.corp.akamai.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT Cc: linux-fsdevel@vger.kernel.org To: Abhijit Paithankar Return-path: Received: from sca-es-mail-1.Sun.COM ([192.18.43.132]:65433 "EHLO sca-es-mail-1.sun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752637AbYIOCbd (ORCPT ); Sun, 14 Sep 2008 22:31:33 -0400 Received: from fe-sfbay-10.sun.com ([192.18.43.129]) by sca-es-mail-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id m8F2VSsb024409 for ; Sun, 14 Sep 2008 19:31:30 -0700 (PDT) Received: from conversion-daemon.fe-sfbay-10.sun.com by fe-sfbay-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0K7700901TEUHJ00@fe-sfbay-10.sun.com> (original mail from adilger@sun.com) for linux-fsdevel@vger.kernel.org; Sun, 14 Sep 2008 19:31:28 -0700 (PDT) In-reply-to: <20080912220649.GB26999@apaithan-desktop.sanmateo.corp.akamai.com> Content-disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sep 12, 2008 15:06 -0700, Abhijit Paithankar wrote: > On journaling file systems, applications need to know when the meta-data > changes to files are written to disks in a manner which is persistent to > crashes and reboots. > > One way to do it is to fsync every few operations. However, fsync is > blocking and affects performance. > > The other (more efficient) way is to have the filesystem notify the > application when a transaction/change is written to disk. > > This patch implements such a notification mechanism based on inotify for > Ext3 and Ext4. > > Every time an application creates, renames, unlinks, etc a file or > directory, a journal_cookie is sent via the inotify mechanism. Ofcourse, > the application has to first register for such notifications on the > files/directories of interest. > > Once the transaction corresponding to that journal_cookie is committed > to the journal another notification is sent to the application > indicating that the change is now persistent. We had a much more flexible journal commit notification mechanism. The caller would register a callback with the journal layer that contained a caller-private callback function and callback data. This avoided exposing the journal transaction IDs outside of the filesystem, and the caller could use any identifier desired. There was also no limit on the number/type of callbacks registered with the filesystem. The basic data structure was a linked list of callbacks registered on the transaction: struct journal_callback { struct list_head jcb_list; void (*jcb_func)(struct journal_callback *jcb, int error); /* caller data goes here */ }; and in journal_commit_transaction() the callbacks are called: list_for_each_entry_safe(jcb, n, &commit_transaction->t_jcb, jcb_list) { list_del_init(&jcb->jcb_list); jcb->jcb_func(jcb, error); } Cheers, Andreas -- Andreas Dilger Sr. Staff Engineer, Lustre Group Sun Microsystems of Canada, Inc.