All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
To: Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 08/45] CIFS: Move unlink code to ops struct
Date: Wed, 12 Sep 2012 15:48:04 -0400	[thread overview]
Message-ID: <20120912154804.19b97830@corrin.poochiereds.net> (raw)
In-Reply-To: <1342626541-29872-9-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>

On Wed, 18 Jul 2012 19:48:24 +0400
Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> wrote:

> Signed-off-by: Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
> ---
>  fs/cifs/cifsglob.h  |    6 ++++++
>  fs/cifs/cifsproto.h |    9 ++++++---
>  fs/cifs/cifssmb.c   |   16 ++++++++--------
>  fs/cifs/inode.c     |   32 +++++++++++++++++++++-----------
>  fs/cifs/smb1ops.c   |    2 ++
>  5 files changed, 43 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index a5b4e82..bd53d97 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -256,6 +256,12 @@ struct smb_version_operations {
>  	/* remove directory */
>  	int (*rmdir)(const unsigned int, struct cifs_tcon *, const char *,
>  		     struct cifs_sb_info *);
> +	/* unlink file */
> +	int (*unlink)(const unsigned int, struct cifs_tcon *, const char *,
> +		      struct cifs_sb_info *);
> +	/* open, rename and delete file */
> +	int (*rename_pending_delete)(const char *, struct dentry *,
> +				     const unsigned int);
>  };
>  
>  struct smb_version_values {
> diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
> index 43784ee..e9349af 100644
> --- a/fs/cifs/cifsproto.h
> +++ b/fs/cifs/cifsproto.h
> @@ -144,6 +144,11 @@ extern int cifs_get_file_info_unix(struct file *filp);
>  extern int cifs_get_inode_info_unix(struct inode **pinode,
>  			const unsigned char *search_path,
>  			struct super_block *sb, unsigned int xid);
> +extern int cifs_set_file_info(struct inode *inode, struct iattr *attrs,
> +			      unsigned int xid, char *full_path, __u32 dosattr);
> +extern int cifs_rename_pending_delete(const char *full_path,
> +				      struct dentry *dentry,
> +				      const unsigned int xid);
>  extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
>  			      struct cifs_fattr *fattr, struct inode *inode,
>  			      const char *path, const __u16 *pfid);
> @@ -303,9 +308,7 @@ extern int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon,
>  			const struct nls_table *nls_codepage,
>  			int remap_special_chars);
>  extern int CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
> -			const char *name,
> -			const struct nls_table *nls_codepage,
> -			int remap_special_chars);
> +			  const char *name, struct cifs_sb_info *cifs_sb);
>  extern int CIFSSMBRename(const unsigned int xid, struct cifs_tcon *tcon,
>  			const char *fromName, const char *toName,
>  			const struct nls_table *nls_codepage,
> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
> index 9fb21cd..395f3e2 100644
> --- a/fs/cifs/cifssmb.c
> +++ b/fs/cifs/cifssmb.c
> @@ -902,15 +902,15 @@ PsxDelete:
>  }
>  
>  int
> -CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
> -	       const char *fileName, const struct nls_table *nls_codepage,
> -	       int remap)
> +CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
> +	       struct cifs_sb_info *cifs_sb)
>  {
>  	DELETE_FILE_REQ *pSMB = NULL;
>  	DELETE_FILE_RSP *pSMBr = NULL;
>  	int rc = 0;
>  	int bytes_returned;
>  	int name_len;
> +	int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
>  
>  DelFileRetry:
>  	rc = smb_init(SMB_COM_DELETE, 1, tcon, (void **) &pSMB,
> @@ -919,15 +919,15 @@ DelFileRetry:
>  		return rc;
>  
>  	if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
> -		name_len =
> -		    cifsConvertToUTF16((__le16 *) pSMB->fileName, fileName,
> -				       PATH_MAX, nls_codepage, remap);
> +		name_len = cifsConvertToUTF16((__le16 *) pSMB->fileName, name,
> +					      PATH_MAX, cifs_sb->local_nls,
> +					      remap);
>  		name_len++;	/* trailing null */
>  		name_len *= 2;
>  	} else {		/* BB improve check for buffer overruns BB */
> -		name_len = strnlen(fileName, PATH_MAX);
> +		name_len = strnlen(name, PATH_MAX);
>  		name_len++;	/* trailing null */
> -		strncpy(pSMB->fileName, fileName, name_len);
> +		strncpy(pSMB->fileName, name, name_len);
>  	}
>  	pSMB->SearchAttributes =
>  	    cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM);
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index 88afb1a..9685eb1 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -878,9 +878,9 @@ out:
>  	return inode;
>  }
>  
> -static int
> +int
>  cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
> -		    char *full_path, __u32 dosattr)
> +		   char *full_path, __u32 dosattr)
>  {
>  	int rc;
>  	int oplock = 0;
> @@ -995,13 +995,13 @@ out:
>  }
>  
>  /*
> - * open the given file (if it isn't already), set the DELETE_ON_CLOSE bit
> + * Open the given file (if it isn't already), set the DELETE_ON_CLOSE bit
>   * and rename it to a random name that hopefully won't conflict with
>   * anything else.
>   */
> -static int
> -cifs_rename_pending_delete(char *full_path, struct dentry *dentry,
> -			   unsigned int xid)
> +int
> +cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
> +			   const unsigned int xid)
>  {
>  	int oplock = 0;
>  	int rc;
> @@ -1138,6 +1138,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
>  	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
>  	struct tcon_link *tlink;
>  	struct cifs_tcon *tcon;
> +	struct TCP_Server_Info *server;
>  	struct iattr *attrs = NULL;
>  	__u32 dosattr = 0, origattr = 0;
>  
> @@ -1147,6 +1148,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
>  	if (IS_ERR(tlink))
>  		return PTR_ERR(tlink);
>  	tcon = tlink_tcon(tlink);
> +	server = tcon->ses->server;
>  
>  	xid = get_xid();
>  
> @@ -1169,8 +1171,12 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
>  	}
>  
>  retry_std_delete:
> -	rc = CIFSSMBDelFile(xid, tcon, full_path, cifs_sb->local_nls,
> -			cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
> +	if (!server->ops->unlink) {
> +		rc = -ENOSYS;
> +		goto psx_del_no_retry;
> +	}
> +
> +	rc = server->ops->unlink(xid, tcon, full_path, cifs_sb);
>  
>  psx_del_no_retry:
>  	if (!rc) {
> @@ -1179,9 +1185,13 @@ psx_del_no_retry:
>  	} else if (rc == -ENOENT) {
>  		d_drop(dentry);
>  	} else if (rc == -ETXTBSY) {
> -		rc = cifs_rename_pending_delete(full_path, dentry, xid);
> -		if (rc == 0)
> -			cifs_drop_nlink(inode);
> +		if (server->ops->rename_pending_delete) {
> +			rc = server->ops->rename_pending_delete(full_path,
> +								dentry, xid);
> +			if (rc == 0)
> +				cifs_drop_nlink(inode);
> +		} else
> +			rc = -ENOSYS;
>  	} else if ((rc == -EACCES) && (dosattr == 0) && inode) {
>  		attrs = kzalloc(sizeof(*attrs), GFP_KERNEL);
>  		if (attrs == NULL) {
> diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
> index 3129ac7..725fa61 100644
> --- a/fs/cifs/smb1ops.c
> +++ b/fs/cifs/smb1ops.c
> @@ -644,6 +644,8 @@ struct smb_version_operations smb1_operations = {
>  	.mkdir = CIFSSMBMkDir,
>  	.mkdir_setinfo = cifs_mkdir_setinfo,
>  	.rmdir = CIFSSMBRmDir,
> +	.unlink = CIFSSMBDelFile,
> +	.rename_pending_delete = cifs_rename_pending_delete,
>  };
>  
>  struct smb_version_values smb1_values = {

Hmm...ACK I guess...

I think it might have been better to just make a single "unlink"
function and do the "rename_pending_delete" stuff within that instead
of abstracting that out too. Not a huge deal though...

-- 
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>

  parent reply	other threads:[~2012-09-12 19:48 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 15:48 [PATCH 00/45] SMB2 base operation support Pavel Shilovsky
     [not found] ` <1342626541-29872-1-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-07-18 15:48   ` [PATCH 01/45] CIFS: Make CAP_* checks protocol independent Pavel Shilovsky
     [not found]     ` <1342626541-29872-2-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-07-23 13:55       ` Jeff Layton
     [not found]         ` <CAKywueTxSBkBfp4wZW8Hy71F3dZ1gsthuHcLVO28--a4oEAMjw@mail.gmail.com>
     [not found]           ` <CAKywueTxSBkBfp4wZW8Hy71F3dZ1gsthuHcLVO28--a4oEAMjw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-07-24  6:37             ` Pavel Shilovsky
2012-07-23 20:59       ` Jeff Layton
     [not found]         ` <20120723165947.5fad3d87-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2012-07-23 21:14           ` Steve French
2012-07-24  6:38           ` Pavel Shilovsky
2012-07-24  7:21       ` [PATCH v2 1/45] " Pavel Shilovsky
     [not found]         ` <1343114502-7908-1-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-07-24 17:44           ` Jeff Layton
2012-07-18 15:48   ` [PATCH 02/45] CIFS: Simpliify cifs_mkdir call Pavel Shilovsky
     [not found]     ` <1342626541-29872-3-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-08-01 19:39       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 03/45] CIFS: Separate protocol specific part from mkdir Pavel Shilovsky
     [not found]     ` <1342626541-29872-4-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-08-01 19:41       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 04/45] CIFS: Add SMB2 support for mkdir operation Pavel Shilovsky
     [not found]     ` <1342626541-29872-5-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-08-01 19:42       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 05/45] CIFS: Move rmdir code to ops struct Pavel Shilovsky
     [not found]     ` <1342626541-29872-6-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-08-01 19:45       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 06/45] CIFS: Add SMB2 support for rmdir Pavel Shilovsky
     [not found]     ` <1342626541-29872-7-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-08-01 19:47       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 07/45] CIFS: Protect i_nlink from being negative Pavel Shilovsky
     [not found]     ` <1342626541-29872-8-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-07-28 11:48       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 08/45] CIFS: Move unlink code to ops struct Pavel Shilovsky
     [not found]     ` <1342626541-29872-9-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-09-12 19:48       ` Jeff Layton [this message]
     [not found]         ` <20120912154804.19b97830-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2012-09-12 20:10           ` Jeff Layton
     [not found]             ` <20120912161038.4c32810a-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2012-09-13  6:04               ` Pavel Shilovsky
     [not found]                 ` <CAKywueTvDNzQQVG0TEvhu2CxEERQc9dxH-VuUwmgOf5d7eeniA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-09-13  6:12                   ` [PATCH v2 9/45] " Pavel Shilovsky
     [not found]                     ` <1347516738-6861-1-git-send-email-pshilovsky-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-09-13 12:07                       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 09/45] CIFS: Add SMB2 support for unlink Pavel Shilovsky
     [not found]     ` <1342626541-29872-10-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-09-12 19:51       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 10/45] CIFS: Replace netfid with cifs_fid struct in cifsFileInfo Pavel Shilovsky
     [not found]     ` <1342626541-29872-11-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-09-12 19:55       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 11/45] CIFS: Move open code to ops struct Pavel Shilovsky
     [not found]     ` <1342626541-29872-12-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-09-12 20:12       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 12/45] CIFS: Move close " Pavel Shilovsky
     [not found]     ` <1342626541-29872-13-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-09-13 15:45       ` Jeff Layton
2012-07-18 15:48   ` [PATCH 13/45] CIFS: Add open/close file support for SMB2 Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 14/45] CIFS: Move guery file info code to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 15/45] CIFS: Add SMB2 support for query_file_info Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 16/45] CIFS: Move create code use ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 17/45] CIFS: Move reopen code to " Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 18/45] CIFS: Make flush code use " Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 19/45] CIFS: Add SMB2 support for flush Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 20/45] CIFS: Move r/wsize negotiating to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 21/45] CIFS: Add SMB2 r/wsize negotiating Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 22/45] CIFS: Move async read to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 23/45] CIFS: Add SMB2 support for cifs_iovec_read Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 24/45] CIFS: Move async write to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 25/45] CIFS: Add SMB2 support for cifs_iovec_write Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 26/45] CIFS: Move readpage code to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 27/45] CIFS: Add readpage support for SMB2 Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 28/45] CIFS: Move writepage to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 29/45] CIFS: Add writepage support for SMB2 Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 30/45] CIFS: Enable signing in SMB2 Pavel Shilovsky
     [not found]     ` <1342626541-29872-31-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-08-21  7:35       ` Stefan Metzmacher
2012-08-21 14:01         ` Pavel Shilovsky
2012-08-21 14:58         ` Shirish Pargaonkar
     [not found]           ` <CADT32e+4DSN=CSCbL+8GoRePknpD3X0HSq1hjVsXf3KHXQcmTw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-08-22 13:46             ` Stefan (metze) Metzmacher
     [not found]               ` <5034E29E.7030006-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2013-07-08  6:15                 ` Shirish Pargaonkar
2012-07-18 15:48   ` [PATCH 31/45] CIFS: Move rename to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 32/45] CIFS: Add SMB2 support for rename operation Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 33/45] CIFS: Move hardlink to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 34/45] CIFS: Add SMB2 support for hardlink operation Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 35/45] CIFS: Move set_file_size to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 36/45] CIFS: Add SMB2 support for set_file_size Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 37/45] CIFS: Move set_file_info to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 38/45] CIFS: Add set_file_info support for SMB2 Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 39/45] CIFS: Move readdir code to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 40/45] CIFS: Add readdir support for SMB2 Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 41/45] CIFS: Process oplocks " Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 42/45] CIFS: Move oplock break to ops struct Pavel Shilovsky
2012-07-18 15:48   ` [PATCH 43/45] CIFS: Add oplock break support for SMB2 Pavel Shilovsky
2012-07-18 15:49   ` [PATCH 44/45] CIFS: Move statfs to ops struct Pavel Shilovsky
2012-07-18 15:49   ` [PATCH 45/45] CIFS: Add statfs support for SMB2 Pavel Shilovsky
2012-08-03 15:14   ` [PATCH 00/45] SMB2 base operation support Steve French

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120912154804.19b97830@corrin.poochiereds.net \
    --to=jlayton-eunubhrolfbytjvyw6ydsg@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.