[linux-cifs-client] Re: CIFS client leaving cifs???? files

Steve French smfltc at us.ibm.com
Wed Jan 3 14:44:58 GMT 2007


> this I've found out that in order for open files to get deleted the client
> (cifs fs in this case) needs to set DELETE_ON_CLOSE when opening the file.
> This is only available when using also using CIFS_XATTR and CIFS_POSIX and
> ea support enabled on the server side.

Use by the client of the delete on close flag does not seem to be related
to CIFS_XATTR or CIFS_POSIX.   See below excerpt from the cifs
delete code in fs/cifs/inode.c

        rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb->local_nls,
                        cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);

        if (!rc) {
                if (direntry->d_inode)
                        drop_nlink(direntry->d_inode);
        } else if (rc == -ENOENT) {
                d_drop(direntry);
        } else if (rc == -ETXTBSY) {
                int oplock = FALSE;
                __u16 netfid;

                rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE,
                                 CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE,
                                 &netfid, &oplock, NULL, cifs_sb->local_nls,
                                 cifs_sb->mnt_cifs_flags &
                                        CIFS_MOUNT_MAP_SPECIAL_CHR);
                if (rc==0) {
                        CIFSSMBRenameOpenFile(xid, pTcon, netfid, NULL,
                                              cifs_sb->local_nls,
                                              cifs_sb->mnt_cifs_flags &
                                                CIFS_MOUNT_MAP_SPECIAL_CHR);


CIFS attempts to delete the file, then if that fails, cifs opens it with the
CREATE_DELETE_ON_CLOSE flag and then renames the file (to null apparently)
then closes it.   This seems to work - and I just confirmed it by opening
a file (even putting a write lock on it) with cifs to Samba 3.0.24pre
Maybe this fails on older servers? or when the Unix Extensions are turned
off?

jra,
Doesn't setting "CREATE_DELETE_ON_CLOSE" work to Samba?  I don't remmeber this path being
a problem.


> > > 1. Open file
> > > 2. Gradually truncate the file
> > > 3. When the file gets below a certain file size, unlink it
> > > 4. Close file
> > >
> > > This behavior has a side effect of leaving the truncated files hanging
> > > around but renamed as cifs??? files. Ie:

> >
> > Hmmm. Steve - how about using the CIFS UNIX call SMB_SET_FILE_UNIX_BASIC
> > (trans2 call info level 0x200) with a st_nlink count of zero and a
> > file type of UNIX_TYPE_FILE (0) to unlink a file ? That way would
> > work for open files without having to invent a new UNIX_unlink
> > call ? Currently st_nlink of zero is used in a "special" way
> > to do mknod calls so there is precedence for this ?





More information about the linux-cifs-client mailing list