@@ -63,6 +63,7 @@ static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int
6363static DECLARE_RWSEM (gfs2_umount_flush_sem );
6464static struct dentry * gfs2_root ;
6565static struct workqueue_struct * glock_workqueue ;
66+ struct workqueue_struct * gfs2_delete_workqueue ;
6667static LIST_HEAD (lru_list );
6768static atomic_t lru_count = ATOMIC_INIT (0 );
6869static DEFINE_SPINLOCK (lru_lock );
@@ -167,7 +168,7 @@ static void glock_free(struct gfs2_glock *gl)
167168 *
168169 */
169170
170- static void gfs2_glock_hold (struct gfs2_glock * gl )
171+ void gfs2_glock_hold (struct gfs2_glock * gl )
171172{
172173 GLOCK_BUG_ON (gl , atomic_read (& gl -> gl_ref ) == 0 );
173174 atomic_inc (& gl -> gl_ref );
@@ -222,7 +223,7 @@ static void gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl)
222223 * to the glock, in addition to the one it is dropping.
223224 */
224225
225- static void gfs2_glock_put_nolock (struct gfs2_glock * gl )
226+ void gfs2_glock_put_nolock (struct gfs2_glock * gl )
226227{
227228 if (atomic_dec_and_test (& gl -> gl_ref ))
228229 GLOCK_BUG_ON (gl , 1 );
@@ -679,6 +680,29 @@ __acquires(&gl->gl_spin)
679680 goto out ;
680681}
681682
683+ static void delete_work_func (struct work_struct * work )
684+ {
685+ struct gfs2_glock * gl = container_of (work , struct gfs2_glock , gl_delete );
686+ struct gfs2_sbd * sdp = gl -> gl_sbd ;
687+ struct gfs2_inode * ip = NULL ;
688+ struct inode * inode ;
689+ u64 no_addr = 0 ;
690+
691+ spin_lock (& gl -> gl_spin );
692+ ip = (struct gfs2_inode * )gl -> gl_object ;
693+ if (ip )
694+ no_addr = ip -> i_no_addr ;
695+ spin_unlock (& gl -> gl_spin );
696+ if (ip ) {
697+ inode = gfs2_ilookup (sdp -> sd_vfs , no_addr );
698+ if (inode ) {
699+ d_prune_aliases (inode );
700+ iput (inode );
701+ }
702+ }
703+ gfs2_glock_put (gl );
704+ }
705+
682706static void glock_work_func (struct work_struct * work )
683707{
684708 unsigned long delay = 0 ;
@@ -757,6 +781,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
757781 gl -> gl_sbd = sdp ;
758782 gl -> gl_aspace = NULL ;
759783 INIT_DELAYED_WORK (& gl -> gl_work , glock_work_func );
784+ INIT_WORK (& gl -> gl_delete , delete_work_func );
760785
761786 /* If this glock protects actual on-disk data or metadata blocks,
762787 create a VFS inode to manage the pages/buffers holding them. */
@@ -898,6 +923,8 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state,
898923 gl -> gl_demote_state != state ) {
899924 gl -> gl_demote_state = LM_ST_UNLOCKED ;
900925 }
926+ if (gl -> gl_ops -> go_callback )
927+ gl -> gl_ops -> go_callback (gl );
901928 trace_gfs2_demote_rq (gl );
902929}
903930
@@ -1344,14 +1371,14 @@ static int gfs2_shrink_glock_memory(int nr, gfp_t gfp_mask)
13441371 spin_unlock (& lru_lock );
13451372 spin_lock (& gl -> gl_spin );
13461373 may_demote = demote_ok (gl );
1347- spin_unlock (& gl -> gl_spin );
1348- clear_bit (GLF_LOCK , & gl -> gl_flags );
13491374 if (may_demote ) {
13501375 handle_callback (gl , LM_ST_UNLOCKED , 0 );
13511376 nr -- ;
13521377 }
13531378 if (queue_delayed_work (glock_workqueue , & gl -> gl_work , 0 ) == 0 )
1354- gfs2_glock_put (gl );
1379+ gfs2_glock_put_nolock (gl );
1380+ spin_unlock (& gl -> gl_spin );
1381+ clear_bit (GLF_LOCK , & gl -> gl_flags );
13551382 spin_lock (& lru_lock );
13561383 continue ;
13571384 }
@@ -1738,6 +1765,11 @@ int __init gfs2_glock_init(void)
17381765 glock_workqueue = create_workqueue ("glock_workqueue" );
17391766 if (IS_ERR (glock_workqueue ))
17401767 return PTR_ERR (glock_workqueue );
1768+ gfs2_delete_workqueue = create_workqueue ("delete_workqueue" );
1769+ if (IS_ERR (gfs2_delete_workqueue )) {
1770+ destroy_workqueue (glock_workqueue );
1771+ return PTR_ERR (gfs2_delete_workqueue );
1772+ }
17411773
17421774 register_shrinker (& glock_shrinker );
17431775
@@ -1748,6 +1780,7 @@ void gfs2_glock_exit(void)
17481780{
17491781 unregister_shrinker (& glock_shrinker );
17501782 destroy_workqueue (glock_workqueue );
1783+ destroy_workqueue (gfs2_delete_workqueue );
17511784}
17521785
17531786static int gfs2_glock_iter_next (struct gfs2_glock_iter * gi )
0 commit comments