diff options
| -rw-r--r-- | libglusterfs/src/iatt.h | 47 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 62 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-helpers.h | 2 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-rpc-fops.c | 30 | 
4 files changed, 141 insertions, 0 deletions
diff --git a/libglusterfs/src/iatt.h b/libglusterfs/src/iatt.h index 8cb2b4a5b27..68a81fa9cd0 100644 --- a/libglusterfs/src/iatt.h +++ b/libglusterfs/src/iatt.h @@ -72,6 +72,27 @@ struct iatt {          ia_prot_t    ia_prot;       /* protection */  }; +struct old_iatt { +        uint64_t     ia_ino;        /* inode number */ +        uuid_t       ia_gfid; +        uint64_t     ia_dev;        /* backing device ID */ +        ia_type_t    ia_type;       /* type of file */ +        ia_prot_t    ia_prot;       /* protection */ +        uint32_t     ia_nlink;      /* Link count */ +        uint32_t     ia_uid;        /* user ID of owner */ +        uint32_t     ia_gid;        /* group ID of owner */ +        uint64_t     ia_rdev;       /* device ID (if special file) */ +        uint64_t     ia_size;       /* file size in bytes */ +        uint32_t     ia_blksize;    /* blocksize for filesystem I/O */ +        uint64_t     ia_blocks;     /* number of 512B blocks allocated */ +        uint32_t     ia_atime;      /* last access time */ +        uint32_t     ia_atime_nsec; +        uint32_t     ia_mtime;      /* last modification time */ +        uint32_t     ia_mtime_nsec; +        uint32_t     ia_ctime;      /* last status change time */ +        uint32_t     ia_ctime_nsec; +}; +  /* 64-bit mask for valid members in struct iatt. */  #define IATT_TYPE             0x0000000000000001U  #define IATT_MODE             0x0000000000000002U @@ -376,6 +397,32 @@ iatt_to_stat (struct iatt *iatt, struct stat *stat)          return 0;  } +static inline void +oldiatt_from_iatt (struct old_iatt *o_iatt, struct iatt *c_iatt) +{ +        o_iatt->ia_dev        = c_iatt->ia_dev; +        o_iatt->ia_ino        = c_iatt->ia_ino; +        o_iatt->ia_type       = c_iatt->ia_type; +        o_iatt->ia_prot       = c_iatt->ia_prot; +        o_iatt->ia_nlink      = c_iatt->ia_nlink; +        o_iatt->ia_uid        = c_iatt->ia_uid; +        o_iatt->ia_gid        = c_iatt->ia_gid; +        o_iatt->ia_rdev       = c_iatt->ia_rdev; +        o_iatt->ia_size       = c_iatt->ia_size; +        o_iatt->ia_blksize    = c_iatt->ia_blksize; +        o_iatt->ia_blocks     = c_iatt->ia_blocks; +        o_iatt->ia_atime      = c_iatt->ia_atime; +        o_iatt->ia_atime_nsec = c_iatt->ia_atime_nsec; +        o_iatt->ia_mtime      = c_iatt->ia_mtime; +        o_iatt->ia_mtime_nsec = c_iatt->ia_mtime_nsec; +        o_iatt->ia_ctime      = c_iatt->ia_ctime; +        o_iatt->ia_ctime_nsec = c_iatt->ia_ctime_nsec; + +        gf_uuid_copy (o_iatt->ia_gfid, c_iatt->ia_gfid); + +        return; +} +  static inline int  is_same_mode (ia_prot_t prot1, ia_prot_t prot2)  { diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 31eb2510cf8..8d6a81fe1e2 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -1221,6 +1221,38 @@ getactivelkinfo_rsp_cleanup_v2 (gfx_getactivelk_rsp  *rsp)  }  int +replace_old_iatt_in_dict (dict_t *xdata) +{ +        int ret; +        struct old_iatt *o_iatt; /* old iatt structure */ +        struct iatt *c_iatt; /* current iatt */ +        int32_t len = sizeof(struct old_iatt); + +        if (!xdata) { +                return 0; +        } + +        ret = dict_get_bin (xdata, DHT_IATT_IN_XDATA_KEY, (void **)&c_iatt); +        if (ret < 0) { +                return 0; +        } + +        o_iatt = GF_CALLOC (1, len, gf_common_mt_char); +        if (!o_iatt) { +                return -1; +        } + +        oldiatt_from_iatt (o_iatt, c_iatt); + +        ret = dict_set_bin (xdata, DHT_IATT_IN_XDATA_KEY, o_iatt, len); +        if (ret) { +                GF_FREE (o_iatt); +        } + +        return ret; +} + +int  gf_server_check_getxattr_cmd (call_frame_t *frame, const char *key)  { @@ -2462,6 +2494,12 @@ server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,                  rsp_args = &this_rsp->compound_rsp_u.compound_unlink_rsp; +                if (replace_old_iatt_in_dict (this_args_cbk->xdata)) { +                        rsp_args->op_errno = errno; +                        rsp_args->op_ret = -1; +                        goto out; +                } +                  GF_PROTOCOL_DICT_SERIALIZE (this, this_args_cbk->xdata,                                              &rsp_args->xdata.xdata_val,                                              rsp_args->xdata.xdata_len, @@ -2724,6 +2762,12 @@ server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,                  rsp_args = &this_rsp->compound_rsp_u.compound_setxattr_rsp; +                if (replace_old_iatt_in_dict (this_args_cbk->xdata)) { +                        rsp_args->op_errno = errno; +                        rsp_args->op_ret = -1; +                        goto out; +                } +                  GF_PROTOCOL_DICT_SERIALIZE (this, this_args_cbk->xdata,                                              &rsp_args->xdata.xdata_val,                                              rsp_args->xdata.xdata_len, @@ -2762,6 +2806,12 @@ server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,                  rsp_args = &this_rsp->compound_rsp_u.compound_removexattr_rsp; +                if (replace_old_iatt_in_dict (this_args_cbk->xdata)) { +                        rsp_args->op_errno = errno; +                        rsp_args->op_ret = -1; +                        goto out; +                } +                  GF_PROTOCOL_DICT_SERIALIZE (this, this_args_cbk->xdata,                                              &rsp_args->xdata.xdata_val,                                              rsp_args->xdata.xdata_len, @@ -3093,6 +3143,12 @@ server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,                  rsp_args = &this_rsp->compound_rsp_u.compound_setxattr_rsp; +                if (replace_old_iatt_in_dict (this_args_cbk->xdata)) { +                        rsp_args->op_errno = errno; +                        rsp_args->op_ret = -1; +                        goto out; +                } +                  GF_PROTOCOL_DICT_SERIALIZE (this, this_args_cbk->xdata,                                              &rsp_args->xdata.xdata_val,                                              rsp_args->xdata.xdata_len, @@ -3197,6 +3253,12 @@ server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,                  rsp_args = &this_rsp->compound_rsp_u.compound_fremovexattr_rsp; +                if (replace_old_iatt_in_dict (this_args_cbk->xdata)) { +                        rsp_args->op_errno = errno; +                        rsp_args->op_ret = -1; +                        goto out; +                } +                  GF_PROTOCOL_DICT_SERIALIZE (this, this_args_cbk->xdata,                                              &rsp_args->xdata.xdata_val,                                              rsp_args->xdata.xdata_len, diff --git a/xlators/protocol/server/src/server-helpers.h b/xlators/protocol/server/src/server-helpers.h index b89105a355f..73e2b89b21f 100644 --- a/xlators/protocol/server/src/server-helpers.h +++ b/xlators/protocol/server/src/server-helpers.h @@ -74,6 +74,8 @@ getactivelkinfo_rsp_cleanup (gfs3_getactivelk_rsp  *rsp);  int  getactivelkinfo_rsp_cleanup_v2 (gfx_getactivelk_rsp  *rsp); +int replace_old_iatt_in_dict (dict_t *); +  int  server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,                                     call_frame_t *frame, diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c index 8fcc93c788f..690e1ebf890 100644 --- a/xlators/protocol/server/src/server-rpc-fops.c +++ b/xlators/protocol/server/src/server-rpc-fops.c @@ -724,6 +724,12 @@ server_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          server_state_t      *state = NULL;          gf_loglevel_t        loglevel = GF_LOG_NONE; +        if (replace_old_iatt_in_dict (xdata)) { +                op_errno = errno; +                op_ret = -1; +                goto out; +        } +          GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val,                                      rsp.xdata.xdata_len, op_errno, out); @@ -766,6 +772,12 @@ server_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          rpcsvc_request_t    *req   = NULL;          server_state_t      *state = NULL; +        if (replace_old_iatt_in_dict (xdata)) { +                op_errno = errno; +                op_ret = -1; +                goto out; +        } +          GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val,                                      rsp.xdata.xdata_len, op_errno, out); @@ -909,6 +921,12 @@ server_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          rpcsvc_request_t *req = NULL;          server_state_t      *state = NULL; +        if (replace_old_iatt_in_dict (xdata)) { +                op_errno = errno; +                op_ret = -1; +                goto out; +        } +          GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val,                                      rsp.xdata.xdata_len, op_errno, out); @@ -974,6 +992,12 @@ server_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          rpcsvc_request_t *req = NULL;          server_state_t      *state = NULL; +        if (replace_old_iatt_in_dict (xdata)) { +                op_errno = errno; +                op_ret = -1; +                goto out; +        } +          GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val,                                      rsp.xdata.xdata_len, op_errno, out); @@ -1066,6 +1090,12 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          server_state_t      *state  = NULL;          rpcsvc_request_t    *req    = NULL; +        if (replace_old_iatt_in_dict (xdata)) { +                op_errno = errno; +                op_ret = -1; +                goto out; +        } +          GF_PROTOCOL_DICT_SERIALIZE (this, xdata, &rsp.xdata.xdata_val,                                      rsp.xdata.xdata_len, op_errno, out);  | 
