Skip to contentSkip to conversation

cifs: allocate dedicated cifsiod_workqueue

PATCH In review Jeff Layton 2 participants 7 messages Feb 17, 2012 – Feb 20, 2012 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover cifs: allocate dedicated cifsiod_workqueue

As Alan Stern pointed out yesterday, cifs queues most of its workqueue jobs to the system_nrt_wq. There are a couple of problems with that:

1/ That workqueue isn't freezable. Some workqueue jobs from cifs (like
oplock breaks) can take quite some time to run since they have to kickoff writeback. That can end up making the freezer give up in some cases.

2/ We queue the async write completion handler to this codepath. Since
that can be called in memory reclaim codepaths, we really ought to be queueing it to a workqueue with WQ_MEM_RECLAIM set.

This patch fixes this by allocating a new workqueue to which we'll queue all the cifs jobs. The first two patches in the series do a little cleanup work in the exit_cifs code, and the last patch adds the new workqueue and has the callers queue their work to it.

This patchset is probably best suited for 3.4.

Jeff Layton (3):
cifs: clean up call to cifs_dfs_release_automount_timer()
cifs: clean up ordering in exit_cifs
cifs: add new cifsiod_wq workqueue

 fs/cifs/cifsfs.c    |   25 +++++++++++++++++--------
 fs/cifs/cifsglob.h  |    1 +
 fs/cifs/cifsproto.h |    6 ++++++
 fs/cifs/cifssmb.c   |    4 ++--
 fs/cifs/connect.c   |    8 ++++----
 fs/cifs/misc.c      |    2 +-
 6 files changed, 31 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.7.6

A message that is not in the archive (sent off-list or not yet received): 1329489104-7823-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH 1/3 cifs: clean up call to cifs_dfs_release_automount_timer()

Take the #ifdef junk out of the code, and turn it into a noop macro when CONFIG_CIFS_DFS_UPCALL isn't defined.

---
 fs/cifs/cifsfs.c    |    2 --
 fs/cifs/cifsproto.h |    6 ++++++
 2 files changed, 6 insertions(+), 2 deletions(-)
fs/cifs/cifsfs.c +0 -2
index b1fd382..f5fa651 100644
@@ -1182,9 +1182,7 @@ exit_cifs(void)
 	cFYI(DBG2, "exit_cifs");
 	cifs_proc_clean();
 	cifs_fscache_unregister();
-#ifdef CONFIG_CIFS_DFS_UPCALL
 	cifs_dfs_release_automount_timer();
-#endif
 #ifdef CONFIG_CIFS_ACL
 	cifs_destroy_idmaptrees();
 	exit_cifs_idmap();
fs/cifs/cifsproto.h +6 -0
index 6f4e243..121b949 100644
@@ -168,7 +168,13 @@ extern struct smb_vol *cifs_get_volume_info(char *mount_data,
 					    const char *devname);
 extern int cifs_mount(struct cifs_sb_info *, struct smb_vol *);
 extern void cifs_umount(struct cifs_sb_info *);
+
+#if IS_ENABLED(CONFIG_CIFS_DFS_UPCALL)
 extern void cifs_dfs_release_automount_timer(void);
+#else /* ! IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) */
+#define cifs_dfs_release_automount_timer()	do { } while(0)
+#endif /* ! IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) */
+
 void cifs_proc_init(void);
 void cifs_proc_clean(void);
 
Signature · 1 line
1.7.7.6

A message that is not in the archive (sent off-list or not yet received): 1329489104-7823-2-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#4 lore raw

Re: [PATCH 1/3] cifs: clean up call to cifs_dfs_release_automount_timer()

Quoted 44 lines · Jeff Layton

Take the #ifdef junk out of the code, and turn it into a noop macro when CONFIG_CIFS_DFS_UPCALL isn't defined.

---
 fs/cifs/cifsfs.c    |    2 --
 fs/cifs/cifsproto.h |    6 ++++++

 2 files changed, 6 insertions(+), 2 deletions(-)
fs/cifs/cifsfs.c +0 -2
index b1fd382..f5fa651 100644
@@ -1182,9 +1182,7 @@ exit_cifs(void)
        cFYI(DBG2, "exit_cifs");
        cifs_proc_clean();
        cifs_fscache_unregister();
-#ifdef CONFIG_CIFS_DFS_UPCALL
        cifs_dfs_release_automount_timer();
-#endif
  #ifdef CONFIG_CIFS_ACL
        cifs_destroy_idmaptrees();
        exit_cifs_idmap();
fs/cifs/cifsproto.h +6 -1
index 6f4e243..121b949 100644
@@ -168,7 +168,13 @@ extern struct smb_vol *cifs_get_volume_info(char *mount_data,
                                            const char *devname);
  extern int cifs_mount(struct cifs_sb_info *, struct smb_vol *);
  extern void cifs_umount(struct cifs_sb_info *);
+
+#if IS_ENABLED(CONFIG_CIFS_DFS_UPCALL)
  extern void cifs_dfs_release_automount_timer(void);
+#else /* ! IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) */
+#define cifs_dfs_release_automount_timer()     do { } while(0)
+#endif /* ! IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) */
+
  void cifs_proc_init(void);
  void cifs_proc_clean(void);
 
--

1.7.7.6

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Looks correct.

#5 lore raw

PATCH 2/3 cifs: clean up ordering in exit_cifs

In reply to a message not in the archive

...ensure that we undo things in the reverse order from the way they were done. In truth, the ordering doesn't matter for a lot of these, but it's still better to do it that way to be sure.

---
 fs/cifs/cifsfs.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
fs/cifs/cifsfs.c +5 -5
index f5fa651..a848082 100644
@@ -1180,8 +1180,7 @@ static void __exit
 exit_cifs(void)
 {
 	cFYI(DBG2, "exit_cifs");
-	cifs_proc_clean();
-	cifs_fscache_unregister();
+	unregister_filesystem(&cifs_fs_type);
 	cifs_dfs_release_automount_timer();
 #ifdef CONFIG_CIFS_ACL
 	cifs_destroy_idmaptrees();
@@ -1190,10 +1189,11 @@ exit_cifs(void)
 #ifdef CONFIG_CIFS_UPCALL
 	unregister_key_type(&cifs_spnego_key_type);
 #endif
-	unregister_filesystem(&cifs_fs_type);
-	cifs_destroy_inodecache();
-	cifs_destroy_mids();
 	cifs_destroy_request_bufs();
+	cifs_destroy_mids();
+	cifs_destroy_inodecache();
+	cifs_fscache_unregister();
+	cifs_proc_clean();
 }
 
 MODULE_AUTHOR("Steve French <sfrench-r/[email protected]>");
Signature · 1 line
1.7.7.6

A message that is not in the archive (sent off-list or not yet received): 1329489104-7823-3-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#7 lore raw

Re: [PATCH 2/3] cifs: clean up ordering in exit_cifs

Quoted 41 lines · Jeff Layton

...ensure that we undo things in the reverse order from the way they were done. In truth, the ordering doesn't matter for a lot of these, but it's still better to do it that way to be sure.

---
 fs/cifs/cifsfs.c |   10 +++++-----

 1 files changed, 5 insertions(+), 5 deletions(-)
fs/cifs/cifsfs.c +5 -6
index f5fa651..a848082 100644
@@ -1180,8 +1180,7 @@ static void __exit
  exit_cifs(void)
  {
        cFYI(DBG2, "exit_cifs");
-       cifs_proc_clean();
-       cifs_fscache_unregister();
+       unregister_filesystem(&cifs_fs_type);
        cifs_dfs_release_automount_timer();
  #ifdef CONFIG_CIFS_ACL
        cifs_destroy_idmaptrees();
@@ -1190,10 +1189,11 @@ exit_cifs(void)
  #ifdef CONFIG_CIFS_UPCALL
        unregister_key_type(&cifs_spnego_key_type);
  #endif
-       unregister_filesystem(&cifs_fs_type);
-       cifs_destroy_inodecache();
-       cifs_destroy_mids();
        cifs_destroy_request_bufs();
+       cifs_destroy_mids();
+       cifs_destroy_inodecache();
+       cifs_fscache_unregister();
+       cifs_proc_clean();
  }
 
  MODULE_AUTHOR("Steve French <sfrench-r/[email protected]>");
--

1.7.7.6

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Looks correct.

#8 lore raw

PATCH 3/3 cifs: add new cifsiod_wq workqueue

In reply to a message not in the archive

...and convert existing cifs users of system_nrt_wq to use that instead.

Also, make it freezable, and set WQ_MEM_RECLAIM since we use it to deal with write reply handling.

---
 fs/cifs/cifsfs.c   |   13 ++++++++++++-
 fs/cifs/cifsglob.h |    1 +
 fs/cifs/cifssmb.c  |    4 ++--
 fs/cifs/connect.c  |    8 ++++----
 fs/cifs/misc.c     |    2 +-
 5 files changed, 20 insertions(+), 8 deletions(-)
fs/cifs/cifsfs.c +12 -1
index a848082..8193c92 100644
@@ -90,6 +90,8 @@ extern mempool_t *cifs_sm_req_poolp;
 extern mempool_t *cifs_req_poolp;
 extern mempool_t *cifs_mid_poolp;
 
+struct workqueue_struct	*cifsiod_wq;
+
 static int
 cifs_read_super(struct super_block *sb)
 {
@@ -1121,9 +1123,15 @@ init_cifs(void)
 		cFYI(1, "cifs_max_pending set to max of 256");
 	}
 
+	cifsiod_wq = alloc_workqueue("cifsiod", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
+	if (!cifsiod_wq) {
+		rc = -ENOMEM;
+		goto out_clean_proc;
+	}
+
 	rc = cifs_fscache_register();
 	if (rc)
-		goto out_clean_proc;
+		goto out_destroy_wq;
 
 	rc = cifs_init_inodecache();
 	if (rc)
@@ -1171,6 +1179,8 @@ out_destroy_inodecache:
 	cifs_destroy_inodecache();
 out_unreg_fscache:
 	cifs_fscache_unregister();
+out_destroy_wq:
+	destroy_workqueue(cifsiod_wq);
 out_clean_proc:
 	cifs_proc_clean();
 	return rc;
@@ -1193,6 +1203,7 @@ exit_cifs(void)
 	cifs_destroy_mids();
 	cifs_destroy_inodecache();
 	cifs_fscache_unregister();
+	destroy_workqueue(cifsiod_wq);
 	cifs_proc_clean();
 }
 
fs/cifs/cifsglob.h +1 -0
index 76e7d8b..5d0c4b6 100644
@@ -1027,5 +1027,6 @@ GLOBAL_EXTERN spinlock_t gidsidlock;
 void cifs_oplock_break(struct work_struct *work);
 
 extern const struct slow_work_ops cifs_oplock_break_ops;
+extern struct workqueue_struct *cifsiod_wq;
 
 #endif	/* _CIFS_GLOB_H */
fs/cifs/cifssmb.c +2 -2
index 8b7794c..4fb1643 100644
@@ -1667,7 +1667,7 @@ cifs_readv_callback(struct mid_q_entry *mid)
 		rdata->result = -EIO;
 	}
 
-	queue_work(system_nrt_wq, &rdata->work);
+	queue_work(cifsiod_wq, &rdata->work);
 	DeleteMidQEntry(mid);
 	atomic_dec(&server->inFlight);
 	wake_up(&server->request_q);
@@ -2108,7 +2108,7 @@ cifs_writev_callback(struct mid_q_entry *mid)
 		break;
 	}
 
-	queue_work(system_nrt_wq, &wdata->work);
+	queue_work(cifsiod_wq, &wdata->work);
 	DeleteMidQEntry(mid);
 	atomic_dec(&tcon->ses->server->inFlight);
 	wake_up(&tcon->ses->server->request_q);
fs/cifs/connect.c +4 -4
index 602f77c..fff5e5d 100644
@@ -334,7 +334,7 @@ cifs_echo_request(struct work_struct *work)
 			server->hostname);
 
 requeue_echo:
-	queue_delayed_work(system_nrt_wq, &server->echo, SMB_ECHO_INTERVAL);
+	queue_delayed_work(cifsiod_wq, &server->echo, SMB_ECHO_INTERVAL);
 }
 
 static bool
@@ -1974,7 +1974,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
 	cifs_fscache_get_client_cookie(tcp_ses);
 
 	/* queue echo request delayed work */
-	queue_delayed_work(system_nrt_wq, &tcp_ses->echo, SMB_ECHO_INTERVAL);
+	queue_delayed_work(cifsiod_wq, &tcp_ses->echo, SMB_ECHO_INTERVAL);
 
 	return tcp_ses;
 
@@ -3539,7 +3539,7 @@ remote_path_check:
 	tlink_rb_insert(&cifs_sb->tlink_tree, tlink);
 	spin_unlock(&cifs_sb->tlink_tree_lock);
 
-	queue_delayed_work(system_nrt_wq, &cifs_sb->prune_tlinks,
+	queue_delayed_work(cifsiod_wq, &cifs_sb->prune_tlinks,
 				TLINK_IDLE_EXPIRE);
 
 mount_fail_check:
@@ -4091,6 +4091,6 @@ cifs_prune_tlinks(struct work_struct *work)
 	}
 	spin_unlock(&cifs_sb->tlink_tree_lock);
 
-	queue_delayed_work(system_nrt_wq, &cifs_sb->prune_tlinks,
+	queue_delayed_work(cifsiod_wq, &cifs_sb->prune_tlinks,
 				TLINK_IDLE_EXPIRE);
 }
fs/cifs/misc.c +1 -1
index 703ef5c..bd215f2 100644
@@ -584,7 +584,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
 
 				cifs_set_oplock_level(pCifsInode,
 					pSMB->OplockLevel ? OPLOCK_READ : 0);
-				queue_work(system_nrt_wq,
+				queue_work(cifsiod_wq,
 					   &netfile->oplock_break);
 				netfile->oplock_break_cancelled = false;
 
Signature · 1 line
1.7.7.6

A message that is not in the archive (sent off-list or not yet received): 1329489104-7823-4-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#10 lore raw

Re: [PATCH 3/3] cifs: add new cifsiod_wq workqueue

Quoted 149 lines · Jeff Layton

...and convert existing cifs users of system_nrt_wq to use that instead.

Also, make it freezable, and set WQ_MEM_RECLAIM since we use it to deal with write reply handling.

---
 fs/cifs/cifsfs.c   |   13 ++++++++++++-
 fs/cifs/cifsglob.h |    1 +
 fs/cifs/cifssmb.c  |    4 ++--
 fs/cifs/connect.c  |    8 ++++----
 fs/cifs/misc.c     |    2 +-

 5 files changed, 20 insertions(+), 8 deletions(-)
fs/cifs/cifsfs.c +2 -0
index a848082..8193c92 100644
@@ -90,6 +90,8 @@ extern mempool_t *cifs_sm_req_poolp;
  extern mempool_t *cifs_req_poolp;
  extern mempool_t *cifs_mid_poolp;
 
+struct workqueue_struct        *cifsiod_wq;
+

 static int
 cifs_read_super(struct super_block *sb)
 {

fs/cifs/cifsfs.c +7 -1
@@ -1121,9 +1123,15 @@ init_cifs(void)
                cFYI(1, "cifs_max_pending set to max of 256");
        }
 
+       cifsiod_wq = alloc_workqueue("cifsiod", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
+       if (!cifsiod_wq) {
+               rc = -ENOMEM;
+               goto out_clean_proc;
+       }
+
        rc = cifs_fscache_register();
        if (rc)
-               goto out_clean_proc;
+               goto out_destroy_wq;
 
        rc = cifs_init_inodecache();
        if (rc)
@@ -1171,6 +1179,8 @@ out_destroy_inodecache:
        cifs_destroy_inodecache();

 out_unreg_fscache:
       cifs_fscache_unregister();
+out_destroy_wq:
+       destroy_workqueue(cifsiod_wq);
 out_clean_proc:
       cifs_proc_clean();
       return rc;

fs/cifs/cifsfs.c +1 -0
@@ -1193,6 +1203,7 @@ exit_cifs(void)
        cifs_destroy_mids();
        cifs_destroy_inodecache();
        cifs_fscache_unregister();
+       destroy_workqueue(cifsiod_wq);
        cifs_proc_clean();
  }
 
fs/cifs/cifsglob.h +1 -0
index 76e7d8b..5d0c4b6 100644
@@ -1027,5 +1027,6 @@ GLOBAL_EXTERN spinlock_t gidsidlock;
  void cifs_oplock_break(struct work_struct *work);
 
  extern const struct slow_work_ops cifs_oplock_break_ops;
+extern struct workqueue_struct *cifsiod_wq;
 
  #endif /* _CIFS_GLOB_H */
fs/cifs/cifssmb.c +2 -2
index 8b7794c..4fb1643 100644
@@ -1667,7 +1667,7 @@ cifs_readv_callback(struct mid_q_entry *mid)
                rdata->result = -EIO;
        }
 
-       queue_work(system_nrt_wq, &rdata->work);
+       queue_work(cifsiod_wq, &rdata->work);
        DeleteMidQEntry(mid);
        atomic_dec(&server->inFlight);
        wake_up(&server->request_q);
@@ -2108,7 +2108,7 @@ cifs_writev_callback(struct mid_q_entry *mid)
                break;
        }
 
-       queue_work(system_nrt_wq, &wdata->work);
+       queue_work(cifsiod_wq, &wdata->work);
        DeleteMidQEntry(mid);
        atomic_dec(&tcon->ses->server->inFlight);
        wake_up(&tcon->ses->server->request_q);
fs/cifs/connect.c +0 -0
index 602f77c..fff5e5d 100644
@@ -334,7 +334,7 @@ cifs_echo_request(struct work_struct *work)
                        server->hostname);
 

 requeue_echo:
-       queue_delayed_work(system_nrt_wq, &server->echo, SMB_ECHO_INTERVAL);
+       queue_delayed_work(cifsiod_wq, &server->echo, SMB_ECHO_INTERVAL); }

 static bool

fs/cifs/connect.c +2 -2
@@ -1974,7 +1974,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
        cifs_fscache_get_client_cookie(tcp_ses);
 
        /* queue echo request delayed work */
-       queue_delayed_work(system_nrt_wq, &tcp_ses->echo, SMB_ECHO_INTERVAL);
+       queue_delayed_work(cifsiod_wq, &tcp_ses->echo, SMB_ECHO_INTERVAL);
 
        return tcp_ses;
 
@@ -3539,7 +3539,7 @@ remote_path_check:
        tlink_rb_insert(&cifs_sb->tlink_tree, tlink);
        spin_unlock(&cifs_sb->tlink_tree_lock);
 
-       queue_delayed_work(system_nrt_wq, &cifs_sb->prune_tlinks,
+       queue_delayed_work(cifsiod_wq, &cifs_sb->prune_tlinks,
                                TLINK_IDLE_EXPIRE);
 

 mount_fail_check:

fs/cifs/connect.c +1 -1
@@ -4091,6 +4091,6 @@ cifs_prune_tlinks(struct work_struct *work)
        }
        spin_unlock(&cifs_sb->tlink_tree_lock);
 
-       queue_delayed_work(system_nrt_wq, &cifs_sb->prune_tlinks,
+       queue_delayed_work(cifsiod_wq, &cifs_sb->prune_tlinks,
                                TLINK_IDLE_EXPIRE);
  }
fs/cifs/misc.c +1 -2
index 703ef5c..bd215f2 100644
@@ -584,7 +584,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
 
                                cifs_set_oplock_level(pCifsInode,
                                        pSMB->OplockLevel ? OPLOCK_READ : 0);
-                               queue_work(system_nrt_wq,
+                               queue_work(cifsiod_wq,
                                           &netfile->oplock_break);
                                netfile->oplock_break_cancelled = false;
 
--

1.7.7.6

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Looks correct.