All of lore.kernel.org
 help / color / mirror / Atom feed
* removing lock_kernel() from fs/fat
@ 2007-10-12 17:18 Little, Chris
  2007-10-12 19:28 ` Matthew Wilcox
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Little, Chris @ 2007-10-12 17:18 UTC (permalink / raw)
  To: kernel-janitors

Background:
Not much.  Some C. Have been using Linux since pre-1.0 and s390 Linux
admin for the last seven years or so.  I've been following kernel
janitors and lkml (lkml when i can) for awhile now.  Also reading "Linux
Kernel Development" by Robert Love.

Now:
Saw in the janitor list about removing lock_kernel().  Created the
following patch for linux/fs/fat against vanilla 2.6.23, but I have some
questions.

1.  In file.c, line 304:
	lock_kernel();
	fat_free(inode, nr_clusters);
	unlock_kernel();

	Why wrap fat_free with lock_kernel and not lock in the function
itself?

2.  In inode.c, starting at lines 439 and 570, the two functions
fat_clear_inode() and fat_write_inode() lock_kernel and then spin lock.
Why the spin lock if it already has the bkl?  Since the spin locks are
used, it makes me less sure of this.  I didn't touch lock_kernel() in
inode.c at all.  In fact I'm almost positive I'm missing something, but
I'm here to learn.  So here it is:

--- linux-2.6.23/fs/fat/dir.c   2007-10-09 15:31:38.000000000 -0500
+++ linux-2.6.23-jcl/fs/fat/dir.c     2007-10-12 11:02:17.000000000
-0500
@@ -459,8 +459,9 @@
        int chi, chl, i, i2, j, last, last_u, dotoffset = 0;
        loff_t cpos;
        int ret = 0;
+       rwlock_t mr_rwlock = RW_LOCK_UNLOCKED;
 
-       lock_kernel();
+       read_lock(&mr_rwlock);
 
        cpos = filp->f_pos;
        /* Fake . and .. for the root directory. */
@@ -642,7 +643,7 @@
        if (unicode)
                free_page((unsigned long)unicode);
 out:
-       unlock_kernel();
+       read_unlock(&mr_rwlock);
        return ret;
 }
 
diff -ur linux-2.6.23/fs/fat/file.c linux-2.6.23-jcl/fs/fat/file.c
--- linux-2.6.23/fs/fat/file.c  2007-10-09 15:31:38.000000000 -0500
+++ linux-2.6.23-jcl/fs/fat/file.c    2007-10-12 11:37:47.000000000
-0500
@@ -160,8 +160,9 @@
        struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb);
        struct inode *inode = dentry->d_inode;
        int mask, error = 0;
+       rwlock_t mr_rwlock = RW_LOCK_UNLOCKED;
 
-       lock_kernel();
+       write_lock(&mr_rwlock);
 
        /*
         * Expand the file. Since inode_setattr() updates ->i_size
@@ -206,7 +207,7 @@
                mask = sbi->options.fs_fmask;
        inode->i_mode &= S_IFMT | (S_IRWXUGO & ~mask);
 out:
-       unlock_kernel();
+       write_unlock(&mr_rwlock);
        return error;
 }
 
@@ -287,6 +288,7 @@
        struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
        const unsigned int cluster_size = sbi->cluster_size;
        int nr_clusters;
+       rwlock_t mr_rwlock = RW_LOCK_UNLOCKED;
 
        /*
         * This protects against truncating a file bigger than it was
then
@@ -297,9 +299,9 @@
 
        nr_clusters = (inode->i_size + (cluster_size - 1)) >>
sbi->cluster_bits;
 
-       lock_kernel();
+       write_lock(&mr_rwlock);
        fat_free(inode, nr_clusters);
-       unlock_kernel();
+       write_lock(&mr_rwlock);
        fat_flush_inodes(inode->i_sb, inode, NULL);
 }

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-10-15 18:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-12 17:18 removing lock_kernel() from fs/fat Little, Chris
2007-10-12 19:28 ` Matthew Wilcox
2007-10-15 16:34 ` Little, Chris
2007-10-15 16:39 ` Little, Chris
2007-10-15 18:23 ` Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.