Skip to content

Commit

Permalink
ceph: use separate class for ceph sockets' sk_lock
Browse files Browse the repository at this point in the history
Use a separate class for ceph sockets to prevent lockdep confusion.
Because ceph sockets only get passed kernel pointers, there is no
dependency from sk_lock -> mmap_sem.  If we share the same class as other
sockets, lockdep detects a circular dependency from

	mmap_sem (page fault) -> fs mutex -> sk_lock -> mmap_sem

because dependencies are noted from both ceph and user contexts.  Using
a separate class prevents the sk_lock(ceph) -> mmap_sem dependency and
makes lockdep happy.

Signed-off-by: Sage Weil <sage@newdream.net>
  • Loading branch information
Sage Weil committed Apr 13, 2010
1 parent e1e4dd0 commit a6a5349
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fs/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ static char tag_msg = CEPH_MSGR_TAG_MSG;
static char tag_ack = CEPH_MSGR_TAG_ACK;
static char tag_keepalive = CEPH_MSGR_TAG_KEEPALIVE;

#ifdef CONFIG_LOCKDEP
static struct lock_class_key socket_class;
#endif


static void queue_con(struct ceph_connection *con);
static void con_work(struct work_struct *);
Expand Down Expand Up @@ -227,6 +231,10 @@ static struct socket *ceph_tcp_connect(struct ceph_connection *con)
con->sock = sock;
sock->sk->sk_allocation = GFP_NOFS;

#ifdef CONFIG_LOCKDEP
lockdep_set_class(&sock->sk->sk_lock, &socket_class);
#endif

set_sock_callbacks(sock, con);

dout("connect %s\n", pr_addr(&con->peer_addr.in_addr));
Expand Down

0 comments on commit a6a5349

Please sign in to comment.