_writeAt bytes to the file at off if release is set then it releases the mutex just before doing the IO call with lock held
(b []byte, off int64, release bool)
| 327 | // |
| 328 | // call with lock held |
| 329 | func (fh *RWFileHandle) _writeAt(b []byte, off int64, release bool) (n int, err error) { |
| 330 | defer log.Trace(fh.logPrefix(), "size=%d, off=%d", len(b), off)("n=%d, err=%v", &n, &err) |
| 331 | if fh.closed { |
| 332 | return n, ECLOSED |
| 333 | } |
| 334 | if fh.readOnly() { |
| 335 | return n, EBADF |
| 336 | } |
| 337 | if err = fh.openPending(); err != nil { |
| 338 | return n, err |
| 339 | } |
| 340 | if fh.flags&os.O_APPEND != 0 { |
| 341 | // From open(2): Before each write(2), the file offset is |
| 342 | // positioned at the end of the file, as if with lseek(2). |
| 343 | size := fh._size() |
| 344 | fh.offset = size |
| 345 | off = fh.offset |
| 346 | } |
| 347 | fh.writeCalled = true |
| 348 | if release { |
| 349 | // Do the writing with fh.mu unlocked |
| 350 | fh.mu.Unlock() |
| 351 | } |
| 352 | n, err = fh.item.WriteAt(b, off) |
| 353 | if release { |
| 354 | fh.mu.Lock() |
| 355 | } |
| 356 | if err != nil { |
| 357 | return n, err |
| 358 | } |
| 359 | |
| 360 | _ = fh._size() |
| 361 | return n, err |
| 362 | } |
| 363 | |
| 364 | // WriteAt bytes to the file at off |
| 365 | func (fh *RWFileHandle) WriteAt(b []byte, off int64) (n int, err error) { |