Commit 38585ccc authored by Andreas Dilger's avatar Andreas Dilger Committed by Greg Kroah-Hartman

staging/lustre/llite: fix O_TMPFILE/O_LOV_DELAY_CREATE conflict

In kernel 3.11 O_TMPFILE was introduced, but the open flag value
conflicts with the O_LOV_DELAY_CREATE flag 020000000 previously used
by Lustre-aware applications.  O_LOV_DELAY_CREATE allows applications
to defer file layout and object creation from open time (the default)
until it can instead be specified by the application using an ioctl.

Instead of trying to find a non-conflicting O_LOV_DELAY_CREATE flag
or define a Lustre-specific flag that isn't of use to most/any other
filesystems, use (O_NOCTTY|FASYNC) as the new value.  These flags
are not meaningful for newly-created regular files and should be
OK since O_LOV_DELAY_CREATE is only meaningful for new files.

I looked into using O_ACCMODE/FMODE_WRITE_IOCTL, which allows calling
ioctl() on the minimally-opened fd and is close to what is needed,
but that doesn't allow specifying the actual read or write mode for
the file, and fcntl(F_SETFL) doesn't allow O_RDONLY/O_WRONLY/O_RDWR
to be set after the file is opened.

Lustre-change: http://review.whamcloud.com/8312
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4209Signed-off-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarPeng Tao <bergwolf@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7345fb75
...@@ -265,13 +265,11 @@ struct ost_id { ...@@ -265,13 +265,11 @@ struct ost_id {
#define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */ #define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */
/* Hopefully O_LOV_DELAY_CREATE does not conflict with standard O_xxx flags. /* Define O_LOV_DELAY_CREATE to be a mask that is not useful for regular
* Previously it was defined as 0100000000 and conflicts with FMODE_NONOTIFY * files, but are unlikely to be used in practice and are not harmful if
* which was added since kernel 2.6.36, so we redefine it as 020000000. * used incorrectly. O_NOCTTY and FASYNC are only meaningful for character
* To be compatible with old version's statically linked binary, finally we * devices and are safe for use on new files (See LU-812, LU-4209). */
* define it as (020000000 | 0100000000). #define O_LOV_DELAY_CREATE (O_NOCTTY | FASYNC)
* */
#define O_LOV_DELAY_CREATE 0120000000
#define LL_FILE_IGNORE_LOCK 0x00000001 #define LL_FILE_IGNORE_LOCK 0x00000001
#define LL_FILE_GROUP_LOCKED 0x00000002 #define LL_FILE_GROUP_LOCKED 0x00000002
......
...@@ -166,6 +166,17 @@ void it_clear_disposition(struct lookup_intent *it, int flag); ...@@ -166,6 +166,17 @@ void it_clear_disposition(struct lookup_intent *it, int flag);
void it_set_disposition(struct lookup_intent *it, int flag); void it_set_disposition(struct lookup_intent *it, int flag);
int it_open_error(int phase, struct lookup_intent *it); int it_open_error(int phase, struct lookup_intent *it);
static inline bool cl_is_lov_delay_create(unsigned int flags)
{
return (flags & O_LOV_DELAY_CREATE) == O_LOV_DELAY_CREATE;
}
static inline void cl_lov_delay_create_clear(unsigned int *flags)
{
if ((*flags & O_LOV_DELAY_CREATE) == O_LOV_DELAY_CREATE)
*flags &= ~O_LOV_DELAY_CREATE;
}
/** @} mdc */ /** @} mdc */
#endif #endif
...@@ -671,14 +671,13 @@ int ll_file_open(struct inode *inode, struct file *file) ...@@ -671,14 +671,13 @@ int ll_file_open(struct inode *inode, struct file *file)
ll_capa_open(inode); ll_capa_open(inode);
if (!lli->lli_has_smd) { if (!lli->lli_has_smd &&
if (file->f_flags & O_LOV_DELAY_CREATE || (cl_is_lov_delay_create(file->f_flags) ||
!(file->f_mode & FMODE_WRITE)) { (file->f_mode & FMODE_WRITE) == 0)) {
CDEBUG(D_INODE, "object creation was delayed\n"); CDEBUG(D_INODE, "object creation was delayed\n");
GOTO(out_och_free, rc); GOTO(out_och_free, rc);
}
} }
file->f_flags &= ~O_LOV_DELAY_CREATE; cl_lov_delay_create_clear(&file->f_flags);
GOTO(out_och_free, rc); GOTO(out_och_free, rc);
out_och_free: out_och_free:
...@@ -1381,23 +1380,25 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, ...@@ -1381,23 +1380,25 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
ccc_inode_lsm_put(inode, lsm); ccc_inode_lsm_put(inode, lsm);
CDEBUG(D_IOCTL, "stripe already exists for ino %lu\n", CDEBUG(D_IOCTL, "stripe already exists for ino %lu\n",
inode->i_ino); inode->i_ino);
return -EEXIST; GOTO(out, rc = -EEXIST);
} }
ll_inode_size_lock(inode); ll_inode_size_lock(inode);
rc = ll_intent_file_open(file, lum, lum_size, &oit); rc = ll_intent_file_open(file, lum, lum_size, &oit);
if (rc) if (rc)
GOTO(out, rc); GOTO(out_unlock, rc);
rc = oit.d.lustre.it_status; rc = oit.d.lustre.it_status;
if (rc < 0) if (rc < 0)
GOTO(out_req_free, rc); GOTO(out_req_free, rc);
ll_release_openhandle(file->f_dentry, &oit); ll_release_openhandle(file->f_dentry, &oit);
out: out_unlock:
ll_inode_size_unlock(inode); ll_inode_size_unlock(inode);
ll_intent_release(&oit); ll_intent_release(&oit);
ccc_inode_lsm_put(inode, lsm); ccc_inode_lsm_put(inode, lsm);
out:
cl_lov_delay_create_clear(&file->f_flags);
return rc; return rc;
out_req_free: out_req_free:
ptlrpc_req_finished((struct ptlrpc_request *) oit.d.lustre.it_data); ptlrpc_req_finished((struct ptlrpc_request *) oit.d.lustre.it_data);
......
...@@ -197,7 +197,7 @@ static __u64 mds_pack_open_flags(__u64 flags, __u32 mode) ...@@ -197,7 +197,7 @@ static __u64 mds_pack_open_flags(__u64 flags, __u32 mode)
if (flags & FMODE_EXEC) if (flags & FMODE_EXEC)
cr_flags |= MDS_FMODE_EXEC; cr_flags |= MDS_FMODE_EXEC;
#endif #endif
if (flags & O_LOV_DELAY_CREATE) if (cl_is_lov_delay_create(flags))
cr_flags |= MDS_OPEN_DELAY_CREATE; cr_flags |= MDS_OPEN_DELAY_CREATE;
if (flags & O_NONBLOCK) if (flags & O_NONBLOCK)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment