CIFS: text file busy

March 2010


A user complains that on his computer, he cannot remove an old firefox lock:

rm -f .mozilla/firefox/n5471qdb.default/.parentlock
rm: cannot remove `.mozilla/firefox/n5471qdb.default/.parentlock': Text file busy

The wd is ~, and mounted via CIFS, with oplocking turned off. Irrespective of that, there is still a lock on that file, there are even two, according to the server:

smbstatus |grep -i lock
<snip>
Locked files:
Pid          Uid        DenyMode   Access      R/W        Oplock           SharePath   Name   Time
<snip>
22762        10107437   DENY_NONE  0x120116    WRONLY     NONE             /lwphome/p107437   .mozilla/firefox/n5371qdb.default/.parentlock   Tue Mar  2 08:20:13 2010
11621        10107437   DENY_NONE  0x10000     RDONLY     NONE             /lwphome/p107437   .mozilla/firefox/n5371qdb.default/.parentlock   Tue Mar  2 15:56:32 2010
32            

The server also says that this particular user has many other files open:

sudo smbstatus |grep -i 107437
<snip>
22762        10107437   DENY_NONE  0x12019f    RDWR       NONE             /lwphome/p107437   .mozilla/firefox/n5371qdb.default/search.sqlite   Tue Mar  2 08:20:14 2010
11621        10107437   DENY_NONE  0x12019f    RDWR       NONE             /lwphome/p107437   .mozilla/firefox/n5371qdb.default/search.sqlite   Tue Mar  2 16:16:08 2010
11668        10107437   DENY_NONE  0x12019f    RDWR       NONE             /lwphome/p107437   .mozilla/firefox/n5371qdb.default/search.sqlite   Tue Mar  2 16:17:38 2010
22762        10107437   DENY_NONE  0x12019f    RDWR       NONE             /lwphome/p107437   .mozilla/firefox/n5371qdb.default/key3.db   Tue Mar  2 08:20:14 2010
<snip>

Meanwhile on the samba client, even though the user is logged off everywhere, the home directory is still mounted. Yet according to lsof, the .parentlock is not open. Rebooting doesn't help.

Questions: How do we remove the file? Will flock -u be of any help? And how does the user remove it? And how do we reproduce the situation? And why is the share still mounted?

Another case:

server$ smbstatus
<snip>
Locked files:
Pid          Uid        DenyMode   Access      R/W        Oplock           SharePath   Name   Time
--------------------------------------------------------------------------------------------------
<snip>
29835        10252438   DENY_NONE  0x120116    WRONLY     NONE             /lwphome/p252438   .mozilla/firefox/qkgzlwdt.default/.parentlock   Wed Apr 14 15:55:59 2010
<snip>

And after a lot of searching, the solution is excruciatingly simple:

user@client:~/.mozilla/firefox/qkgzlwdt.default$ mv .parentlock was.paren
user@client:~/.mozilla/firefox/qkgzlwdt.default$ rm was.paren
user@client:~/.mozilla/firefox/qkgzlwdt.default$

Now let's wait for another instance of the problem to see whether the mv is a solution, or this was a coincidence...