Skip to content

Commit eaff807

Browse files
Christoph HellwigAl Viro
authored andcommitted
kill I_LOCK
After I_SYNC was split from I_LOCK the leftover is always used together with I_NEW and thus superflous. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 7a0ad10 commit eaff807

9 files changed

Lines changed: 39 additions & 44 deletions

File tree

‎fs/gfs2/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static struct inode *gfs2_iget_skip(struct super_block *sb,
125125
* directory entry when gfs2_inode_lookup() is invoked. Part of the code
126126
* segment inside gfs2_inode_lookup code needs to get moved around.
127127
*
128-
* Clean up I_LOCK and I_NEW as well.
128+
* Clears I_NEW as well.
129129
**/
130130

131131
void gfs2_set_iop(struct inode *inode)

‎fs/inode.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void wake_up_inode(struct inode *inode)
113113
* Prevent speculative execution through spin_unlock(&inode_lock);
114114
*/
115115
smp_mb();
116-
wake_up_bit(&inode->i_state, __I_LOCK);
116+
wake_up_bit(&inode->i_state, __I_NEW);
117117
}
118118

119119
/**
@@ -690,17 +690,17 @@ void unlock_new_inode(struct inode *inode)
690690
}
691691
#endif
692692
/*
693-
* This is special! We do not need the spinlock when clearing I_LOCK,
693+
* This is special! We do not need the spinlock when clearing I_NEW,
694694
* because we're guaranteed that nobody else tries to do anything about
695695
* the state of the inode when it is locked, as we just created it (so
696-
* there can be no old holders that haven't tested I_LOCK).
696+
* there can be no old holders that haven't tested I_NEW).
697697
* However we must emit the memory barrier so that other CPUs reliably
698-
* see the clearing of I_LOCK after the other inode initialisation has
698+
* see the clearing of I_NEW after the other inode initialisation has
699699
* completed.
700700
*/
701701
smp_mb();
702-
WARN_ON((inode->i_state & (I_LOCK|I_NEW)) != (I_LOCK|I_NEW));
703-
inode->i_state &= ~(I_LOCK|I_NEW);
702+
WARN_ON(!(inode->i_state & I_NEW));
703+
inode->i_state &= ~I_NEW;
704704
wake_up_inode(inode);
705705
}
706706
EXPORT_SYMBOL(unlock_new_inode);
@@ -731,7 +731,7 @@ static struct inode *get_new_inode(struct super_block *sb,
731731
goto set_failed;
732732

733733
__inode_add_to_lists(sb, head, inode);
734-
inode->i_state = I_LOCK|I_NEW;
734+
inode->i_state = I_NEW;
735735
spin_unlock(&inode_lock);
736736

737737
/* Return the locked inode with I_NEW set, the
@@ -778,7 +778,7 @@ static struct inode *get_new_inode_fast(struct super_block *sb,
778778
if (!old) {
779779
inode->i_ino = ino;
780780
__inode_add_to_lists(sb, head, inode);
781-
inode->i_state = I_LOCK|I_NEW;
781+
inode->i_state = I_NEW;
782782
spin_unlock(&inode_lock);
783783

784784
/* Return the locked inode with I_NEW set, the
@@ -1083,7 +1083,7 @@ int insert_inode_locked(struct inode *inode)
10831083
ino_t ino = inode->i_ino;
10841084
struct hlist_head *head = inode_hashtable + hash(sb, ino);
10851085

1086-
inode->i_state |= I_LOCK|I_NEW;
1086+
inode->i_state |= I_NEW;
10871087
while (1) {
10881088
struct hlist_node *node;
10891089
struct inode *old = NULL;
@@ -1120,7 +1120,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
11201120
struct super_block *sb = inode->i_sb;
11211121
struct hlist_head *head = inode_hashtable + hash(sb, hashval);
11221122

1123-
inode->i_state |= I_LOCK|I_NEW;
1123+
inode->i_state |= I_NEW;
11241124

11251125
while (1) {
11261126
struct hlist_node *node;
@@ -1510,16 +1510,16 @@ EXPORT_SYMBOL(inode_wait);
15101510
* until the deletion _might_ have completed. Callers are responsible
15111511
* to recheck inode state.
15121512
*
1513-
* It doesn't matter if I_LOCK is not set initially, a call to
1513+
* It doesn't matter if I_NEW is not set initially, a call to
15141514
* wake_up_inode() after removing from the hash list will DTRT.
15151515
*
15161516
* This is called with inode_lock held.
15171517
*/
15181518
static void __wait_on_freeing_inode(struct inode *inode)
15191519
{
15201520
wait_queue_head_t *wq;
1521-
DEFINE_WAIT_BIT(wait, &inode->i_state, __I_LOCK);
1522-
wq = bit_waitqueue(&inode->i_state, __I_LOCK);
1521+
DEFINE_WAIT_BIT(wait, &inode->i_state, __I_NEW);
1522+
wq = bit_waitqueue(&inode->i_state, __I_NEW);
15231523
prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE);
15241524
spin_unlock(&inode_lock);
15251525
schedule();

‎fs/jfs/jfs_txnmgr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ int txCommit(tid_t tid, /* transaction identifier */
12921292
*/
12931293
/*
12941294
* I believe this code is no longer needed. Splitting I_LOCK
1295-
* into two bits, I_LOCK and I_SYNC should prevent this
1295+
* into two bits, I_NEW and I_SYNC should prevent this
12961296
* deadlock as well. But since I don't have a JFS testload
12971297
* to verify this, only a trivial s/I_LOCK/I_SYNC/ was done.
12981298
* Joern

‎fs/ntfs/inode.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ static int ntfs_is_extended_system_file(ntfs_attr_search_ctx *ctx)
530530
* the ntfs inode.
531531
*
532532
* Q: What locks are held when the function is called?
533-
* A: i_state has I_LOCK set, hence the inode is locked, also
533+
* A: i_state has I_NEW set, hence the inode is locked, also
534534
* i_count is set to 1, so it is not going to go away
535535
* i_flags is set to 0 and we have no business touching it. Only an ioctl()
536536
* is allowed to write to them. We should of course be honouring them but
@@ -1207,7 +1207,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
12071207
* necessary fields in @vi as well as initializing the ntfs inode.
12081208
*
12091209
* Q: What locks are held when the function is called?
1210-
* A: i_state has I_LOCK set, hence the inode is locked, also
1210+
* A: i_state has I_NEW set, hence the inode is locked, also
12111211
* i_count is set to 1, so it is not going to go away
12121212
*
12131213
* Return 0 on success and -errno on error. In the error case, the inode will
@@ -1474,7 +1474,7 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
14741474
* normal directory inodes.
14751475
*
14761476
* Q: What locks are held when the function is called?
1477-
* A: i_state has I_LOCK set, hence the inode is locked, also
1477+
* A: i_state has I_NEW set, hence the inode is locked, also
14781478
* i_count is set to 1, so it is not going to go away
14791479
*
14801480
* Return 0 on success and -errno on error. In the error case, the inode will

‎fs/ubifs/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
*
4646
* Similarly, @i_mutex is not always locked in 'ubifs_readpage()', e.g., the
4747
* read-ahead path does not lock it ("sys_read -> generic_file_aio_read ->
48-
* ondemand_readahead -> readpage"). In case of readahead, @I_LOCK flag is not
48+
* ondemand_readahead -> readpage"). In case of readahead, @I_SYNC flag is not
4949
* set as well. However, UBIFS disables readahead.
5050
*/
5151

‎fs/xfs/linux-2.6/xfs_iops.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ xfs_setup_inode(
794794
struct inode *inode = &ip->i_vnode;
795795

796796
inode->i_ino = ip->i_ino;
797-
inode->i_state = I_NEW|I_LOCK;
797+
inode->i_state = I_NEW;
798798
inode_add_to_lists(ip->i_mount->m_super, inode);
799799

800800
inode->i_mode = ip->i_d.di_mode;

‎fs/xfs/xfs_iget.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ xfs_inode_alloc(
9191
ip->i_new_size = 0;
9292

9393
/* prevent anyone from using this yet */
94-
VFS_I(ip)->i_state = I_NEW|I_LOCK;
94+
VFS_I(ip)->i_state = I_NEW;
9595

9696
return ip;
9797
}
@@ -217,7 +217,7 @@ xfs_iget_cache_hit(
217217
trace_xfs_iget_reclaim(ip);
218218
goto out_error;
219219
}
220-
inode->i_state = I_LOCK|I_NEW;
220+
inode->i_state = I_NEW;
221221
} else {
222222
/* If the VFS inode is being torn down, pause and try again. */
223223
if (!igrab(inode)) {

‎include/linux/fs.h‎

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ struct super_operations {
15871587
* until that flag is cleared. I_WILL_FREE, I_FREEING and I_CLEAR are set at
15881588
* various stages of removing an inode.
15891589
*
1590-
* Two bits are used for locking and completion notification, I_LOCK and I_SYNC.
1590+
* Two bits are used for locking and completion notification, I_NEW and I_SYNC.
15911591
*
15921592
* I_DIRTY_SYNC Inode is dirty, but doesn't have to be written on
15931593
* fdatasync(). i_atime is the usual cause.
@@ -1596,8 +1596,14 @@ struct super_operations {
15961596
* don't have to write inode on fdatasync() when only
15971597
* mtime has changed in it.
15981598
* I_DIRTY_PAGES Inode has dirty pages. Inode itself may be clean.
1599-
* I_NEW get_new_inode() sets i_state to I_LOCK|I_NEW. Both
1600-
* are cleared by unlock_new_inode(), called from iget().
1599+
* I_NEW Serves as both a mutex and completion notification.
1600+
* New inodes set I_NEW. If two processes both create
1601+
* the same inode, one of them will release its inode and
1602+
* wait for I_NEW to be released before returning.
1603+
* Inodes in I_WILL_FREE, I_FREEING or I_CLEAR state can
1604+
* also cause waiting on I_NEW, without I_NEW actually
1605+
* being set. find_inode() uses this to prevent returning
1606+
* nearly-dead inodes.
16011607
* I_WILL_FREE Must be set when calling write_inode_now() if i_count
16021608
* is zero. I_FREEING must be set when I_WILL_FREE is
16031609
* cleared.
@@ -1611,20 +1617,11 @@ struct super_operations {
16111617
* prohibited for many purposes. iget() must wait for
16121618
* the inode to be completely released, then create it
16131619
* anew. Other functions will just ignore such inodes,
1614-
* if appropriate. I_LOCK is used for waiting.
1620+
* if appropriate. I_NEW is used for waiting.
16151621
*
1616-
* I_LOCK Serves as both a mutex and completion notification.
1617-
* New inodes set I_LOCK. If two processes both create
1618-
* the same inode, one of them will release its inode and
1619-
* wait for I_LOCK to be released before returning.
1620-
* Inodes in I_WILL_FREE, I_FREEING or I_CLEAR state can
1621-
* also cause waiting on I_LOCK, without I_LOCK actually
1622-
* being set. find_inode() uses this to prevent returning
1623-
* nearly-dead inodes.
1624-
* I_SYNC Similar to I_LOCK, but limited in scope to writeback
1625-
* of inode dirty data. Having a separate lock for this
1626-
* purpose reduces latency and prevents some filesystem-
1627-
* specific deadlocks.
1622+
* I_SYNC Synchonized write of dirty inode data. The bits is
1623+
* set during data writeback, and cleared with a wakeup
1624+
* on the bit address once it is done.
16281625
*
16291626
* Q: What is the difference between I_WILL_FREE and I_FREEING?
16301627
* Q: igrab() only checks on (I_FREEING|I_WILL_FREE). Should it also check on
@@ -1633,13 +1630,12 @@ struct super_operations {
16331630
#define I_DIRTY_SYNC 1
16341631
#define I_DIRTY_DATASYNC 2
16351632
#define I_DIRTY_PAGES 4
1636-
#define I_NEW 8
1633+
#define __I_NEW 3
1634+
#define I_NEW (1 << __I_NEW)
16371635
#define I_WILL_FREE 16
16381636
#define I_FREEING 32
16391637
#define I_CLEAR 64
1640-
#define __I_LOCK 7
1641-
#define I_LOCK (1 << __I_LOCK)
1642-
#define __I_SYNC 8
1638+
#define __I_SYNC 7
16431639
#define I_SYNC (1 << __I_SYNC)
16441640

16451641
#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)

‎include/linux/writeback.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ void wakeup_flusher_threads(long nr_pages);
7979
static inline void wait_on_inode(struct inode *inode)
8080
{
8181
might_sleep();
82-
wait_on_bit(&inode->i_state, __I_LOCK, inode_wait,
83-
TASK_UNINTERRUPTIBLE);
82+
wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE);
8483
}
8584
static inline void inode_sync_wait(struct inode *inode)
8685
{

0 commit comments

Comments
 (0)