@@ -63,8 +63,8 @@ func init() {
63
63
registry .Register ("cephfs" , New )
64
64
}
65
65
66
- // New returns an implementation to of the storage.FS interface that talks to
67
- // a ceph filesystem .
66
+ // New returns an implementation of the storage.FS interface that talks to
67
+ // a CephFS storage via libcephfs .
68
68
func New (ctx context.Context , m map [string ]interface {}) (fs storage.FS , err error ) {
69
69
var o Options
70
70
if err := cfg .Decode (m , & o ); err != nil {
@@ -140,8 +140,10 @@ func (fs *cephfs) CreateDir(ctx context.Context, ref *provider.Reference) error
140
140
return getRevaError (ctx , err )
141
141
}
142
142
143
+ log := appctx .GetLogger (ctx )
143
144
user .op (func (cv * cacheVal ) {
144
145
if err = cv .mount .MakeDir (path , fs .conf .DirPerms ); err != nil {
146
+ log .Debug ().Str ("path" , path ).Err (err ).Msg ("cv.mount.CreateDir returned" )
145
147
return
146
148
}
147
149
})
@@ -157,15 +159,19 @@ func (fs *cephfs) Delete(ctx context.Context, ref *provider.Reference) (err erro
157
159
return err
158
160
}
159
161
162
+ log := appctx .GetLogger (ctx )
160
163
user .op (func (cv * cacheVal ) {
161
164
if err = cv .mount .Unlink (path ); err != nil && err .Error () == errIsADirectory {
162
165
err = cv .mount .RemoveDir (path )
163
166
}
164
167
})
165
168
166
- //has already been deleted by direct mount
167
- if err != nil && err .Error () == errNotFound {
168
- return nil
169
+ if err != nil {
170
+ log .Debug ().Any ("ref" , ref ).Err (err ).Msg ("Delete returned" )
171
+ if err .Error () == errNotFound {
172
+ //has already been deleted by direct mount
173
+ return nil
174
+ }
169
175
}
170
176
171
177
return getRevaError (ctx , err )
@@ -181,8 +187,10 @@ func (fs *cephfs) Move(ctx context.Context, oldRef, newRef *provider.Reference)
181
187
return
182
188
}
183
189
190
+ log := appctx .GetLogger (ctx )
184
191
user .op (func (cv * cacheVal ) {
185
192
if err = cv .mount .Rename (oldPath , newPath ); err != nil {
193
+ log .Debug ().Any ("oldRef" , oldRef ).Any ("newRef" , newRef ).Err (err ).Msg ("cv.mount.Rename returned" )
186
194
return
187
195
}
188
196
})
@@ -200,21 +208,23 @@ func (fs *cephfs) GetMD(ctx context.Context, ref *provider.Reference, mdKeys []s
200
208
return nil , errors .New ("error: ref is nil" )
201
209
}
202
210
211
+ log := appctx .GetLogger (ctx )
203
212
var path string
204
213
user := fs .makeUser (ctx )
205
- log := appctx .GetLogger (ctx )
206
-
207
214
if path , err = user .resolveRef (ref ); err != nil {
208
215
return nil , err
209
216
}
210
217
211
218
user .op (func (cv * cacheVal ) {
212
219
var stat Statx
213
220
if stat , err = cv .mount .Statx (path , goceph .StatxBasicStats , 0 ); err != nil {
221
+ log .Debug ().Str ("path" , path ).Err (err ).Msg ("cv.mount.Statx returned" )
214
222
return
215
223
}
216
224
ri , err = user .fileAsResourceInfo (cv , path , stat , mdKeys )
217
- log .Debug ().Any ("resourceInfo" , ri ).Err (err ).Msg ("fileAsResourceInfo returned" )
225
+ if err != nil {
226
+ log .Debug ().Any ("resourceInfo" , ri ).Err (err ).Msg ("fileAsResourceInfo returned" )
227
+ }
218
228
})
219
229
220
230
return ri , getRevaError (ctx , err )
@@ -273,8 +283,12 @@ func (fs *cephfs) Download(ctx context.Context, ref *provider.Reference) (rc io.
273
283
return nil , errors .Wrap (err , "cephfs: error resolving ref" )
274
284
}
275
285
286
+ log := appctx .GetLogger (ctx )
276
287
user .op (func (cv * cacheVal ) {
277
- rc , err = cv .mount .Open (path , os .O_RDONLY , 0 )
288
+ if rc , err = cv .mount .Open (path , os .O_RDONLY , 0 ); err != nil {
289
+ log .Debug ().Any ("ref" , ref ).Err (err ).Msg ("cv.mount.Open returned" )
290
+ return
291
+ }
278
292
})
279
293
280
294
return rc , getRevaError (ctx , err )
@@ -303,8 +317,11 @@ func (fs *cephfs) AddGrant(ctx context.Context, ref *provider.Reference, g *prov
303
317
return
304
318
}
305
319
320
+ log := appctx .GetLogger (ctx )
306
321
user .op (func (cv * cacheVal ) {
307
- err = fs .changePerms (ctx , cv .mount , g , path , updateGrant )
322
+ if err = fs .changePerms (ctx , cv .mount , g , path , updateGrant ); err != nil {
323
+ log .Debug ().Any ("ref" , ref ).Any ("grant" , g ).Err (err ).Msg ("AddGrant returned" )
324
+ }
308
325
})
309
326
310
327
return getRevaError (ctx , err )
@@ -317,8 +334,11 @@ func (fs *cephfs) RemoveGrant(ctx context.Context, ref *provider.Reference, g *p
317
334
return
318
335
}
319
336
337
+ log := appctx .GetLogger (ctx )
320
338
user .op (func (cv * cacheVal ) {
321
- err = fs .changePerms (ctx , cv .mount , g , path , removeGrant )
339
+ if err = fs .changePerms (ctx , cv .mount , g , path , removeGrant ); err != nil {
340
+ log .Debug ().Any ("ref" , ref ).Any ("grant" , g ).Err (err ).Msg ("RemoveGrant returned" )
341
+ }
322
342
})
323
343
324
344
return getRevaError (ctx , err )
@@ -331,8 +351,11 @@ func (fs *cephfs) UpdateGrant(ctx context.Context, ref *provider.Reference, g *p
331
351
return
332
352
}
333
353
354
+ log := appctx .GetLogger (ctx )
334
355
user .op (func (cv * cacheVal ) {
335
- err = fs .changePerms (ctx , cv .mount , g , path , updateGrant )
356
+ if err = fs .changePerms (ctx , cv .mount , g , path , updateGrant ); err != nil {
357
+ log .Debug ().Any ("ref" , ref ).Any ("grant" , g ).Err (err ).Msg ("UpdateGrant returned" )
358
+ }
336
359
})
337
360
338
361
return getRevaError (ctx , err )
@@ -345,9 +368,12 @@ func (fs *cephfs) DenyGrant(ctx context.Context, ref *provider.Reference, g *pro
345
368
return
346
369
}
347
370
371
+ log := appctx .GetLogger (ctx )
348
372
user .op (func (cv * cacheVal ) {
349
373
grant := & provider.Grant {Grantee : g } //nil perms will remove the whole grant
350
- err = fs .changePerms (ctx , cv .mount , grant , path , removeGrant )
374
+ if err = fs .changePerms (ctx , cv .mount , grant , path , removeGrant ); err != nil {
375
+ log .Debug ().Any ("ref" , ref ).Any ("grant" , grant ).Err (err ).Msg ("DenyGrant returned" )
376
+ }
351
377
})
352
378
353
379
return getRevaError (ctx , err )
@@ -415,13 +441,15 @@ func (fs *cephfs) SetArbitraryMetadata(ctx context.Context, ref *provider.Refere
415
441
return err
416
442
}
417
443
444
+ log := appctx .GetLogger (ctx )
418
445
user .op (func (cv * cacheVal ) {
419
446
for k , v := range md .Metadata {
420
447
if ! strings .HasPrefix (k , xattrUserNs ) {
421
448
k = xattrUserNs + k
422
449
}
423
450
if e := cv .mount .SetXattr (path , k , []byte (v ), 0 ); e != nil {
424
451
err = errors .Wrap (err , e .Error ())
452
+ log .Debug ().Any ("ref" , ref ).Str ("key" , k ).Any ("v" , v ).Err (err ).Msg ("SetXattr returned" )
425
453
return
426
454
}
427
455
}
@@ -437,13 +465,15 @@ func (fs *cephfs) UnsetArbitraryMetadata(ctx context.Context, ref *provider.Refe
437
465
return err
438
466
}
439
467
468
+ log := appctx .GetLogger (ctx )
440
469
user .op (func (cv * cacheVal ) {
441
470
for _ , key := range keys {
442
471
if ! strings .HasPrefix (key , xattrUserNs ) {
443
472
key = xattrUserNs + key
444
473
}
445
474
if e := cv .mount .RemoveXattr (path , key ); e != nil {
446
475
err = errors .Wrap (err , e .Error ())
476
+ log .Debug ().Any ("ref" , ref ).Str ("key" , key ).Err (err ).Msg ("RemoveXattr returned" )
447
477
return
448
478
}
449
479
}
@@ -459,10 +489,12 @@ func (fs *cephfs) TouchFile(ctx context.Context, ref *provider.Reference) error
459
489
return getRevaError (ctx , err )
460
490
}
461
491
492
+ log := appctx .GetLogger (ctx )
462
493
user .op (func (cv * cacheVal ) {
463
494
var file * goceph.File
464
495
defer closeFile (file )
465
496
if file , err = cv .mount .Open (path , os .O_CREATE | os .O_WRONLY , fs .conf .FilePerms ); err != nil {
497
+ log .Debug ().Any ("ref" , ref ).Err (err ).Msg ("Touch: Open returned" )
466
498
return
467
499
}
468
500
})
0 commit comments