From 5f79d6e08fbb930aa67dd59eb39cbece6f138b59 Mon Sep 17 00:00:00 2001 From: Xavier Hernandez Date: Thu, 18 Sep 2014 16:50:47 +0200 Subject: ec: Add config information in an xattr To simplify backward compatibility of the ec xlator when some parameter or the implementation itself is changed, a new xattr is added to each file with the configuration needed to recover it. The new attribute is called 'trusted.ec.config', and it's a 64-bit value containing the following information: 8 bits: version of the config information (currently always 0) 8 bits: algorithm used to encode the file (currently always 0) 8 bits: size of the galois field (currently always 8) 8 bits: number of bricks 8 bits: redundancy 24 bits: chunk size (currently 512) This new xattr could allow, in a future version, to have different configurations per file. Change-Id: I8c12d40ff546cc201fc66caa367484be3d48aeb4 BUG: 1140861 Signed-off-by: Xavier Hernandez Reviewed-on: http://review.gluster.org/8770 Tested-by: Gluster Build System Reviewed-by: Dan Lambright Reviewed-by: Vijay Bellur --- xlators/cluster/ec/src/ec-dir-write.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'xlators/cluster/ec/src/ec-dir-write.c') diff --git a/xlators/cluster/ec/src/ec-dir-write.c b/xlators/cluster/ec/src/ec-dir-write.c index a28b7ad1937..92012855087 100644 --- a/xlators/cluster/ec/src/ec-dir-write.c +++ b/xlators/cluster/ec/src/ec-dir-write.c @@ -149,6 +149,7 @@ void ec_wind_create(ec_t * ec, ec_fop_data_t * fop, int32_t idx) int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state) { + ec_t * ec; ec_cbk_data_t * cbk; ec_fd_t * ctx; @@ -175,6 +176,34 @@ int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state) UNLOCK(&fop->fd->lock); + if (fop->xdata == NULL) + { + fop->xdata = dict_new(); + if (fop->xdata == NULL) + { + fop->error = EIO; + + return EC_STATE_REPORT; + } + } + + ec = fop->xl->private; + + fop->config.version = EC_CONFIG_VERSION; + fop->config.algorithm = EC_CONFIG_ALGORITHM; + fop->config.gf_word_size = EC_GF_BITS; + fop->config.bricks = ec->nodes; + fop->config.redundancy = ec->redundancy; + fop->config.chunk_size = EC_METHOD_CHUNK_SIZE; + + if (ec_dict_set_config(fop->xdata, EC_XATTR_CONFIG, + &fop->config) < 0) + { + fop->error = EIO; + + return EC_STATE_REPORT; + } + fop->int32 &= ~O_ACCMODE; fop->int32 |= O_RDWR; -- cgit