[linux-cifs-client] [PATCH] Cannot allocate memory
Pavel Shilovsky
piastry at etersoft.ru
Tue Mar 10 15:31:36 GMT 2009
Hello!
This patch resolves problem "Cannot allocate memory" during loading
module when we do unload/load quickly. During unloading the
cifs_demultiplex_thread doesn't have enough time for clearing cache and
kmem_cache_destroy fails. Then during loading module it fails with
kmem_cache_create: duplicate cache cifs_request.
This script can show this bug:
rmmod cifs
for i in `seq 1 20`;
do {
echo "trying to mount " $i
insmod ./cifs.ko
cifsmount [имя шары] [путь] -onoperm
umount [путь]
rmmod cifs
};
done
And it fails on 2nd iteration.
My patch fixes it.
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 1ae6314..18ba45a 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -176,6 +176,7 @@ struct TCP_Server_Info {
struct mac_key mac_signing_key;
char ntlmv2_hash[16];
unsigned long lstrp; /* when we got last response from this
server */
+ int running;
};
/*
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index f254235..39daaf2 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -347,6 +347,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
bool isMultiRsp;
int reconnect;
+ server->running = 1;
current->flags |= PF_MEMALLOC;
cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current)));
@@ -758,6 +759,8 @@ multi_t2_fnd:
kfree(server->hostname);
task_to_wake = xchg(&server->tsk, NULL);
+ server->running = 0;
+ msleep(20);
kfree(server);
length = atomic_dec_return(&tcpSesAllocCount);
@@ -1408,6 +1411,9 @@ cifs_put_tcp_session(struct TCP_Server_Info *server)
task = xchg(&server->tsk, NULL);
if (task)
force_sig(SIGKILL, task);
+
+ while(server->running == 1)
+ msleep(10);
}
static struct cifsSesInfo *
--
Best regards,
Pavel Shilovsky.
More information about the linux-cifs-client
mailing list