Project

General

Profile

Actions

Bug #38327

closed

rgw_file: can't retrieve etag of empty object written through NFS

Added by Tao CHEN about 5 years ago. Updated almost 5 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Target version:
-
% Done:

0%

Source:
Tags:
Backport:
luminous, mimic, nautilus
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

Hi all, it seems that empty file written by NFS will get a empty etag and acls.

ceph version: V12.2.5
nfs-ganesha version: V2.6.2

Way to reproduce:

1.start nfs-ganesha server
2.mount export to local, like /mnt
3.cd /mnt && touch empty_file

run a python script in order to get object infoļ¼š

import boto3

s3 = boto3.client(
                's3',
                aws_access_key_id="xxx",
                aws_secret_access_key="xxx",
                endpoint_url="rgw_endpoint_addr")

response = s3.list_objects(
    Bucket='bucket_name'
)

print(response)

here is the results:

{  
  'Name':'bucket1',
  'ResponseMetadata':{  
    'HTTPStatusCode':200,
    'RetryAttempts':0,
    'HostId':'',
    'RequestId':'tx00000000000000000000d-005c663612-114b-default',
    'HTTPHeaders':{  
      'transfer-encoding':'chunked',
      'date':'Fri, 15 Feb 2019 03:46:26 GMT',
      'x-amz-request-id':'tx00000000000000000000d-005c663612-114b-default',
      'content-type':'application/xml'
    }
  },
  'MaxKeys':1000,
  'Prefix':'',
  'Marker':'',
  'EncodingType':'url',
  'IsTruncated':False,
  'Contents':[  
    {  
      'LastModified':datetime.datetime(2019,2,13,6,34,52,478000,tzinfo=tzutc()),
      'ETag':'""',
      'StorageClass':'STANDARD',
      'Key':'ccc',
      'Owner':{  
        'DisplayName':'',
        'ID':''
      },
      'Size':0
    }
  ]
}

ETag got nothing.

Way to resolve

NFS will send a setattr request to backend when create request is done.
In rgw_setattr function, only RGW_ATTR_UNIX_KEY1 and RGW_ATTR_UNIX1 are saved to request, RGW_ATTR_ETAG and RGW_ATTR_ACL are forgotten. though RGW_ATTR_ETAG and RGW_ATTR_ACL are written in rgw_create step, by these two attrs will be efface in rgw_setattr:

int RGWLibFS::setattr(RGWFileHandle* rgw_fh, struct stat* st, uint32_t mask,
            uint32_t flags)
  {
    int rc, rc2;
    buffer::list ux_key, ux_attrs;

    lock_guard guard(rgw_fh->mtx);

    switch(rgw_fh->fh.fh_type) {
    case RGW_FS_TYPE_FILE:
    {
      if (rgw_fh->deleted())
    return -ESTALE;
    }
    break;
    default:
      break;
    };

    string obj_name{rgw_fh->relative_object_name()};

    if (rgw_fh->is_dir() &&
    (likely(! rgw_fh->is_bucket()))) {
      obj_name += "/";
    }

    RGWSetAttrsRequest req(cct, get_user(), rgw_fh->bucket_name(), obj_name);

    rgw_fh->create_stat(st, mask);
    rgw_fh->encode_attrs(ux_key, ux_attrs);

    /* save attrs */
    req.emplace_attr(RGW_ATTR_UNIX_KEY1, std::move(ux_key));
    req.emplace_attr(RGW_ATTR_UNIX1, std::move(ux_attrs));

    rc = rgwlib.get_fe()->execute_req(&req);
    rc2 = req.get_ret();

    if (rc == -ENOENT) {
      /* special case:  materialize placeholder dir */
      buffer::list bl;
      RGWPutObjRequest req(get_context(), get_user(), rgw_fh->bucket_name(),
               obj_name, bl);

      rgw_fh->encode_attrs(ux_key, ux_attrs); /* because std::moved */

      /* save attrs */
      req.emplace_attr(RGW_ATTR_UNIX_KEY1, std::move(ux_key));
      req.emplace_attr(RGW_ATTR_UNIX1, std::move(ux_attrs));

      rc = rgwlib.get_fe()->execute_req(&req);
      rc2 = req.get_ret();
    }

    if ((rc != 0) || (rc2 != 0)) {
      return -EIO;
    }

    rgw_fh->set_ctime(real_clock::to_timespec(real_clock::now()));

    return 0;
  } /* RGWLibFS::setattr */

So I think it will be better to save RGW_ATTR_ETAG and RGW_ATTR_ACL attr in rgw_setattr function.


Related issues 3 (0 open3 closed)

Copied to rgw - Backport #39227: luminous: rgw_file: can't retrieve etag of empty object written through NFSResolvedPrashant DActions
Copied to rgw - Backport #39228: nautilus: rgw_file: can't retrieve etag of empty object written through NFSResolvedPrashant DActions
Copied to rgw - Backport #39229: mimic: rgw_file: can't retrieve etag of empty object written through NFSResolvedPrashant DActions
Actions #1

Updated by Kefu Chai about 5 years ago

  • Project changed from Ceph to rgw
  • Status changed from New to Fix Under Review
  • Pull request ID set to 26439
Actions #4

Updated by Nathan Cutler about 5 years ago

  • Backport set to luminous, mimic

Flagging for backport to luminous, mimic since the bug was reported against luminous.

@Matt Li, please revert this if you don't agree.

Actions #5

Updated by Matt Benjamin about 5 years ago

Hi Nathan,

I do agree, was going to update it.

thanks!

Matt

Actions #6

Updated by Casey Bodley about 5 years ago

  • Assignee set to Matt Benjamin
Actions #7

Updated by Abhishek Lekshmanan about 5 years ago

  • Status changed from Fix Under Review to 7
Actions #8

Updated by J. Eric Ivancich about 5 years ago

  • Status changed from 7 to Pending Backport
Actions #9

Updated by J. Eric Ivancich about 5 years ago

  • Backport changed from luminous, mimic to luminous, mimic, nautilus
Actions #10

Updated by Nathan Cutler about 5 years ago

  • Copied to Backport #39227: luminous: rgw_file: can't retrieve etag of empty object written through NFS added
Actions #11

Updated by Nathan Cutler about 5 years ago

  • Copied to Backport #39228: nautilus: rgw_file: can't retrieve etag of empty object written through NFS added
Actions #12

Updated by Nathan Cutler about 5 years ago

  • Copied to Backport #39229: mimic: rgw_file: can't retrieve etag of empty object written through NFS added
Actions #13

Updated by Nathan Cutler almost 5 years ago

  • Status changed from Pending Backport to Resolved
Actions

Also available in: Atom PDF