|
@ -4,13 +4,11 @@ import ( |
|
|
"bytes" |
|
|
"bytes" |
|
|
"errors" |
|
|
"errors" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"os" |
|
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/glog" |
|
|
"github.com/seaweedfs/seaweedfs/weed/glog" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/backend" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/backend" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle" |
|
|
. "github.com/seaweedfs/seaweedfs/weed/storage/types" |
|
|
. "github.com/seaweedfs/seaweedfs/weed/storage/types" |
|
|
|
|
|
"os" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
var ErrorNotFound = errors.New("not found") |
|
|
var ErrorNotFound = errors.New("not found") |
|
@ -157,7 +155,7 @@ func (v *Volume) doWriteRequest(n *needle.Needle, checkCookie bool) (offset uint |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// append to dat file
|
|
|
// append to dat file
|
|
|
n.AppendAtNs = max(uint64(time.Now().UnixNano()), v.lastAppendAtNs+1) |
|
|
|
|
|
|
|
|
n.UpdateAppendAtNs(v.lastAppendAtNs) |
|
|
offset, size, _, err = n.Append(v.DataBackend, v.Version()) |
|
|
offset, size, _, err = n.Append(v.DataBackend, v.Version()) |
|
|
v.checkReadWriteError(err) |
|
|
v.checkReadWriteError(err) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -218,6 +216,7 @@ func (v *Volume) doDeleteRequest(n *needle.Needle) (Size, error) { |
|
|
size := nv.Size |
|
|
size := nv.Size |
|
|
if !v.hasRemoteFile { |
|
|
if !v.hasRemoteFile { |
|
|
n.Data = nil |
|
|
n.Data = nil |
|
|
|
|
|
n.UpdateAppendAtNs(v.lastAppendAtNs) |
|
|
n.AppendAtNs = uint64(time.Now().UnixNano()) |
|
|
n.AppendAtNs = uint64(time.Now().UnixNano()) |
|
|
offset, _, _, err = n.Append(v.DataBackend, v.Version()) |
|
|
offset, _, _, err = n.Append(v.DataBackend, v.Version()) |
|
|
v.checkReadWriteError(err) |
|
|
v.checkReadWriteError(err) |
|
@ -318,7 +317,7 @@ func (v *Volume) WriteNeedleBlob(needleId NeedleId, needleBlob []byte, size Size |
|
|
return fmt.Errorf("volume size limit %d exceeded! current size is %d", MaxPossibleVolumeSize, v.nm.ContentSize()) |
|
|
return fmt.Errorf("volume size limit %d exceeded! current size is %d", MaxPossibleVolumeSize, v.nm.ContentSize()) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
appendAtNs := uint64(time.Now().UnixNano()) |
|
|
|
|
|
|
|
|
appendAtNs := needle.GetAppendAtNs(v.lastAppendAtNs) |
|
|
offset, err := needle.WriteNeedleBlob(v.DataBackend, needleBlob, size, appendAtNs, v.Version()) |
|
|
offset, err := needle.WriteNeedleBlob(v.DataBackend, needleBlob, size, appendAtNs, v.Version()) |
|
|
|
|
|
|
|
|
v.checkReadWriteError(err) |
|
|
v.checkReadWriteError(err) |
|
@ -334,10 +333,3 @@ func (v *Volume) WriteNeedleBlob(needleId NeedleId, needleBlob []byte, size Size |
|
|
|
|
|
|
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func max(x, y uint64) uint64 { |
|
|
|
|
|
if x <= y { |
|
|
|
|
|
return y |
|
|
|
|
|
} |
|
|
|
|
|
return x |
|
|
|
|
|
} |
|
|
|