Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 321209
b: refs/heads/master
c: 5ef50c3
h: refs/heads/master
i:
  321207: 24533a5
v: v3
  • Loading branch information
Sage Weil committed Aug 2, 2012
1 parent 3bcd863 commit 5c592cf
Show file tree
Hide file tree
Showing 20 changed files with 516 additions and 496 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 410fc4ce8a373a3c35c73ac2c7c29f2bac6400bf
refs/heads/master: 5ef50c3bec20060bc114f62d6503c5d86d70bdd7
38 changes: 0 additions & 38 deletions trunk/fs/ceph/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,44 +633,6 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
return dentry;
}

int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
struct file *file, unsigned flags, umode_t mode,
int *opened)
{
int err;
struct dentry *res = NULL;

if (!(flags & O_CREAT)) {
if (dentry->d_name.len > NAME_MAX)
return -ENAMETOOLONG;

err = ceph_init_dentry(dentry);
if (err < 0)
return err;

return ceph_lookup_open(dir, dentry, file, flags, mode, opened);
}

if (d_unhashed(dentry)) {
res = ceph_lookup(dir, dentry, 0);
if (IS_ERR(res))
return PTR_ERR(res);

if (res)
dentry = res;
}

/* We don't deal with positive dentries here */
if (dentry->d_inode)
return finish_no_open(file, res);

*opened |= FILE_CREATED;
err = ceph_lookup_open(dir, dentry, file, flags, mode, opened);
dput(res);

return err;
}

/*
* If we do a create but get no trace back from the MDS, follow up with
* a lookup (the VFS expects us to link up the provided dentry).
Expand Down
62 changes: 37 additions & 25 deletions trunk/fs/ceph/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/file.h>
#include <linux/mount.h>
#include <linux/namei.h>
#include <linux/writeback.h>

Expand Down Expand Up @@ -106,9 +107,6 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode)
}

/*
* If the filp already has private_data, that means the file was
* already opened by intent during lookup, and we do nothing.
*
* If we already have the requisite capabilities, we can satisfy
* the open request locally (no need to request new caps from the
* MDS). We do, however, need to inform the MDS (asynchronously)
Expand Down Expand Up @@ -207,24 +205,29 @@ int ceph_open(struct inode *inode, struct file *file)


/*
* Do a lookup + open with a single request.
*
* If this succeeds, but some subsequent check in the vfs
* may_open() fails, the struct *file gets cleaned up (i.e.
* ceph_release gets called). So fear not!
* Do a lookup + open with a single request. If we get a non-existent
* file or symlink, return 1 so the VFS can retry.
*/
int ceph_lookup_open(struct inode *dir, struct dentry *dentry,
int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
struct file *file, unsigned flags, umode_t mode,
int *opened)
{
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
struct ceph_mds_client *mdsc = fsc->mdsc;
struct ceph_mds_request *req;
struct dentry *ret;
struct dentry *dn;
int err;

dout("ceph_lookup_open dentry %p '%.*s' flags %d mode 0%o\n",
dentry, dentry->d_name.len, dentry->d_name.name, flags, mode);
dout("atomic_open %p dentry %p '%.*s' %s flags %d mode 0%o\n",
dir, dentry, dentry->d_name.len, dentry->d_name.name,
d_unhashed(dentry) ? "unhashed" : "hashed", flags, mode);

if (dentry->d_name.len > NAME_MAX)
return -ENAMETOOLONG;

err = ceph_init_dentry(dentry);
if (err < 0)
return err;

/* do the open */
req = prepare_open_request(dir->i_sb, flags, mode);
Expand All @@ -241,22 +244,31 @@ int ceph_lookup_open(struct inode *dir, struct dentry *dentry,
(flags & (O_CREAT|O_TRUNC)) ? dir : NULL,
req);
err = ceph_handle_snapdir(req, dentry, err);
if (err)
goto out;
if ((flags & O_CREAT) && !req->r_reply_info.head->is_dentry)
if (err == 0 && (flags & O_CREAT) && !req->r_reply_info.head->is_dentry)
err = ceph_handle_notrace_create(dir, dentry);
if (err)
goto out;
err = finish_open(file, req->r_dentry, ceph_open, opened);
out:
ret = ceph_finish_lookup(req, dentry, err);
ceph_mdsc_put_request(req);
dout("ceph_lookup_open result=%p\n", ret);

if (IS_ERR(ret))
return PTR_ERR(ret);
if (d_unhashed(dentry)) {
dn = ceph_finish_lookup(req, dentry, err);
if (IS_ERR(dn))
err = PTR_ERR(dn);
} else {
/* we were given a hashed negative dentry */
dn = NULL;
}
if (err)
goto out_err;
if (dn || dentry->d_inode == NULL || S_ISLNK(dentry->d_inode->i_mode)) {
/* make vfs retry on splice, ENOENT, or symlink */
dout("atomic_open finish_no_open on dn %p\n", dn);
err = finish_no_open(file, dn);
} else {
dout("atomic_open finish_open on dn %p\n", dn);
err = finish_open(file, dentry, ceph_open, opened);
}

dput(ret);
out_err:
ceph_mdsc_put_request(req);
dout("atomic_open result=%d\n", err);
return err;
}

Expand Down
6 changes: 3 additions & 3 deletions trunk/fs/ceph/super.h
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,9 @@ extern int ceph_copy_from_page_vector(struct page **pages,
loff_t off, size_t len);
extern struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags);
extern int ceph_open(struct inode *inode, struct file *file);
extern int ceph_lookup_open(struct inode *dir, struct dentry *dentry,
struct file *od, unsigned flags,
umode_t mode, int *opened);
extern int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
struct file *file, unsigned flags, umode_t mode,
int *opened);
extern int ceph_release(struct inode *inode, struct file *filp);

/* dir.c */
Expand Down
10 changes: 0 additions & 10 deletions trunk/fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,6 @@ struct smb_version_operations {
bool (*can_echo)(struct TCP_Server_Info *);
/* send echo request */
int (*echo)(struct TCP_Server_Info *);
/* create directory */
int (*mkdir)(const unsigned int, struct cifs_tcon *, const char *,
struct cifs_sb_info *);
/* set info on created directory */
void (*mkdir_setinfo)(struct inode *, const char *,
struct cifs_sb_info *, struct cifs_tcon *,
const unsigned int);
/* remove directory */
int (*rmdir)(const unsigned int, struct cifs_tcon *, const char *,
struct cifs_sb_info *);
};

struct smb_version_values {
Expand Down
11 changes: 7 additions & 4 deletions trunk/fs/cifs/cifsproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,18 @@ extern int CIFSSMBUnixSetFileInfo(const unsigned int xid,
u16 fid, u32 pid_of_opener);

extern int CIFSSMBUnixSetPathInfo(const unsigned int xid,
struct cifs_tcon *tcon, const char *file_name,
struct cifs_tcon *tcon, char *file_name,
const struct cifs_unix_set_info_args *args,
const struct nls_table *nls_codepage,
int remap);
int remap_special_chars);

extern int CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon,
const char *name, struct cifs_sb_info *cifs_sb);
const char *newName,
const struct nls_table *nls_codepage,
int remap_special_chars);
extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
const char *name, struct cifs_sb_info *cifs_sb);
const char *name, const struct nls_table *nls_codepage,
int remap_special_chars);
extern int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon,
const char *name, __u16 type,
const struct nls_table *nls_codepage,
Expand Down
31 changes: 14 additions & 17 deletions trunk/fs/cifs/cifssmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,15 +948,15 @@ CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
}

int
CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
struct cifs_sb_info *cifs_sb)
CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
const char *dirName, const struct nls_table *nls_codepage,
int remap)
{
DELETE_DIRECTORY_REQ *pSMB = NULL;
DELETE_DIRECTORY_RSP *pSMBr = NULL;
int rc = 0;
int bytes_returned;
int name_len;
int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;

cFYI(1, "In CIFSSMBRmDir");
RmDirRetry:
Expand All @@ -966,15 +966,14 @@ CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
return rc;

if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, name,
PATH_MAX, cifs_sb->local_nls,
remap);
name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, dirName,
PATH_MAX, nls_codepage, remap);
name_len++; /* trailing null */
name_len *= 2;
} else { /* BB improve check for buffer overruns BB */
name_len = strnlen(name, PATH_MAX);
name_len = strnlen(dirName, PATH_MAX);
name_len++; /* trailing null */
strncpy(pSMB->DirName, name, name_len);
strncpy(pSMB->DirName, dirName, name_len);
}

pSMB->BufferFormat = 0x04;
Expand All @@ -993,15 +992,14 @@ CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
}

int
CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
struct cifs_sb_info *cifs_sb)
CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon,
const char *name, const struct nls_table *nls_codepage, int remap)
{
int rc = 0;
CREATE_DIRECTORY_REQ *pSMB = NULL;
CREATE_DIRECTORY_RSP *pSMBr = NULL;
int bytes_returned;
int name_len;
int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;

cFYI(1, "In CIFSSMBMkDir");
MkDirRetry:
Expand All @@ -1012,8 +1010,7 @@ CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,

if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, name,
PATH_MAX, cifs_sb->local_nls,
remap);
PATH_MAX, nls_codepage, remap);
name_len++; /* trailing null */
name_len *= 2;
} else { /* BB improve check for buffer overruns BB */
Expand Down Expand Up @@ -5946,7 +5943,7 @@ CIFSSMBUnixSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,

int
CIFSSMBUnixSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
const char *file_name,
char *fileName,
const struct cifs_unix_set_info_args *args,
const struct nls_table *nls_codepage, int remap)
{
Expand All @@ -5967,14 +5964,14 @@ CIFSSMBUnixSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,

if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
name_len =
cifsConvertToUTF16((__le16 *) pSMB->FileName, file_name,
cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName,
PATH_MAX, nls_codepage, remap);
name_len++; /* trailing null */
name_len *= 2;
} else { /* BB improve the check for buffer overruns BB */
name_len = strnlen(file_name, PATH_MAX);
name_len = strnlen(fileName, PATH_MAX);
name_len++; /* trailing null */
strncpy(pSMB->FileName, file_name, name_len);
strncpy(pSMB->FileName, fileName, name_len);
}

params = 6 + name_len;
Expand Down
Loading

0 comments on commit 5c592cf

Please sign in to comment.