mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3914c98d05 | ||
|
|
fe57a2e770 | ||
|
|
dbeeda8123 | ||
|
|
7286e525ad | ||
|
|
2b955c1713 | ||
|
|
f3c1e00521 | ||
|
|
bb9919b07a | ||
|
|
072f923a9b | ||
|
|
3d0e9e5197 | ||
|
|
417b59b893 | ||
|
|
24290fed9d | ||
|
|
6200b6abb1 | ||
|
|
6a921e15f3 | ||
|
|
f8af0f93d9 | ||
|
|
0381338d40 | ||
|
|
a1ef0e48a9 | ||
|
|
be40ff6048 | ||
|
|
3d93570979 | ||
|
|
6a42cb6b0b | ||
|
|
813b868b9a | ||
|
|
e85ca10a1a | ||
|
|
21046c6a28 | ||
|
|
a4c9223b9d | ||
|
|
c81833a192 | ||
|
|
5c48c23235 | ||
|
|
7cfbf1e85f | ||
|
|
4c75fd5f9c | ||
|
|
b0a5193e32 | ||
|
|
661a34e23d | ||
|
|
5e814afe88 | ||
|
|
5a0a709016 | ||
|
|
866981d8ac | ||
|
|
72faae91e1 | ||
|
|
a10c28ba82 | ||
|
|
f4d88862c4 | ||
|
|
180445f5a8 | ||
|
|
45a0fda9bd | ||
|
|
f87da798a4 | ||
|
|
9a913457dd | ||
|
|
b6143de52a | ||
|
|
7a0c35674c | ||
|
|
c3f9d9fa2e | ||
|
|
0c1f42f4eb | ||
|
|
439f0f834d | ||
|
|
47c04db9b3 | ||
|
|
91876bf628 | ||
|
|
7a5a717063 | ||
|
|
f955096e92 | ||
|
|
2065715712 | ||
|
|
1236efb039 | ||
|
|
eb39f78396 | ||
|
|
13cb609f60 | ||
|
|
21aaa4c1f1 | ||
|
|
13f6ec1c4e | ||
|
|
f34c2ff7c5 | ||
|
|
c8c7c10c3f | ||
|
|
0901438bd2 | ||
|
|
f18803424a | ||
|
|
51a5d731ce | ||
|
|
22a3ef56f2 | ||
|
|
9860405974 | ||
|
|
85c1615b43 | ||
|
|
a2ac540ecc | ||
|
|
7f0c793083 | ||
|
|
b1cff07ab0 | ||
|
|
81f86c381d | ||
|
|
f46763d74f | ||
|
|
ef541972f8 | ||
|
|
1b7fb3ce84 | ||
|
|
fb97e234c9 | ||
|
|
9405eaefdb | ||
|
|
433fde4b18 | ||
|
|
a23fcb9a7c | ||
|
|
247bbabda5 | ||
|
|
ced3b89395 | ||
|
|
affe3c2c12 | ||
|
|
76e297d64f | ||
|
|
d8e6bd0a94 | ||
|
|
f3364fec99 | ||
|
|
9978f54acf | ||
|
|
3f4e17aa24 | ||
|
|
6bdc274d4d | ||
|
|
6cf2e7d493 | ||
|
|
a7982bd525 | ||
|
|
b54a65ba5a | ||
|
|
6bee1e9714 | ||
|
|
7270067289 | ||
|
|
84c9bc4389 | ||
|
|
b8490fe427 | ||
|
|
b3f0f170b4 | ||
|
|
b9b684194f | ||
|
|
67e3fe996a | ||
|
|
62d815d1ca | ||
|
|
9596fce562 | ||
|
|
5c9259fa3c | ||
|
|
7328962009 | ||
|
|
c9952759c4 | ||
|
|
28efe31524 | ||
|
|
3bba2124ef | ||
|
|
520591e6ea | ||
|
|
e185d90d24 | ||
|
|
4a311c7f5e | ||
|
|
bb6854b972 | ||
|
|
2bdd737971 | ||
|
|
643bbbeb49 | ||
|
|
18ed06b420 | ||
|
|
8e80f3cd65 | ||
|
|
dde34fa99d | ||
|
|
a2aa542370 | ||
|
|
c376ccc5a5 | ||
|
|
b9ae16fbc5 | ||
|
|
1ee828b768 | ||
|
|
02d0c12cdd | ||
|
|
5dea5c0449 | ||
|
|
8aa6bf0bb9 | ||
|
|
d97bd54e63 | ||
|
|
482014f9da | ||
|
|
3b4a9addaf | ||
|
|
4acfc098e9 | ||
|
|
e71dcfb3a6 | ||
|
|
9d0f58c329 | ||
|
|
ce2049cdb6 | ||
|
|
e47f63d159 | ||
|
|
6e57d8d0de | ||
|
|
606667f205 | ||
|
|
b1063162b6 | ||
|
|
f103491912 | ||
|
|
6c7135d77e | ||
|
|
ea57654e34 | ||
|
|
7c66f3b5fb | ||
|
|
5f3784ee05 | ||
|
|
1dced26304 | ||
|
|
b3e526ba95 | ||
|
|
30b7e03920 | ||
|
|
ee03cb0aa1 | ||
|
|
77c98b657e | ||
|
|
2559d59a9d | ||
|
|
77362700e1 | ||
|
|
30406bca0f |
No files matched your search
@@ -20,12 +20,12 @@ jobs:
|
|||||||
assets: |
|
assets: |
|
||||||
weed-*
|
weed-*
|
||||||
|
|
||||||
build_dev_linux:
|
build_dev_linux_windows:
|
||||||
needs: cleanup
|
needs: cleanup
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
goos: [linux]
|
goos: [linux, windows]
|
||||||
goarch: [amd64]
|
goarch: [amd64]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -68,7 +68,7 @@ jobs:
|
|||||||
asset_name: "weed-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}"
|
asset_name: "weed-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}"
|
||||||
|
|
||||||
build_dev_darwin:
|
build_dev_darwin:
|
||||||
needs: build_dev_linux
|
needs: build_dev_linux_windows
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ Your support will be really appreciated by me and other supporters!
|
|||||||
- [Download Binaries for different platforms](https://github.com/chrislusf/seaweedfs/releases/latest)
|
- [Download Binaries for different platforms](https://github.com/chrislusf/seaweedfs/releases/latest)
|
||||||
- [SeaweedFS on Slack](https://join.slack.com/t/seaweedfs/shared_invite/enQtMzI4MTMwMjU2MzA3LTEyYzZmZWYzOGQ3MDJlZWMzYmI0OTE4OTJiZjJjODBmMzUxNmYwODg0YjY3MTNlMjBmZDQ1NzQ5NDJhZWI2ZmY)
|
- [SeaweedFS on Slack](https://join.slack.com/t/seaweedfs/shared_invite/enQtMzI4MTMwMjU2MzA3LTEyYzZmZWYzOGQ3MDJlZWMzYmI0OTE4OTJiZjJjODBmMzUxNmYwODg0YjY3MTNlMjBmZDQ1NzQ5NDJhZWI2ZmY)
|
||||||
- [SeaweedFS on Twitter](https://twitter.com/SeaweedFS)
|
- [SeaweedFS on Twitter](https://twitter.com/SeaweedFS)
|
||||||
|
- [SeaweedFS on Telegram](https://t.me/Seaweedfs)
|
||||||
- [SeaweedFS Mailing List](https://groups.google.com/d/forum/seaweedfs)
|
- [SeaweedFS Mailing List](https://groups.google.com/d/forum/seaweedfs)
|
||||||
- [Wiki Documentation](https://github.com/chrislusf/seaweedfs/wiki)
|
- [Wiki Documentation](https://github.com/chrislusf/seaweedfs/wiki)
|
||||||
- [SeaweedFS White Paper](https://github.com/chrislusf/seaweedfs/wiki/SeaweedFS_Architecture.pdf)
|
- [SeaweedFS White Paper](https://github.com/chrislusf/seaweedfs/wiki/SeaweedFS_Architecture.pdf)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ ENV ROCKSDB_VERSION v6.22.1
|
|||||||
RUN cd /tmp && \
|
RUN cd /tmp && \
|
||||||
git clone https://github.com/facebook/rocksdb.git /tmp/rocksdb --depth 1 --single-branch --branch $ROCKSDB_VERSION && \
|
git clone https://github.com/facebook/rocksdb.git /tmp/rocksdb --depth 1 --single-branch --branch $ROCKSDB_VERSION && \
|
||||||
cd rocksdb && \
|
cd rocksdb && \
|
||||||
make static_lib && \
|
PORTABLE=1 make static_lib && \
|
||||||
make install-static
|
make install-static
|
||||||
|
|
||||||
ENV CGO_CFLAGS "-I/tmp/rocksdb/include"
|
ENV CGO_CFLAGS "-I/tmp/rocksdb/include"
|
||||||
@@ -29,7 +29,7 @@ FROM alpine AS final
|
|||||||
LABEL author="Chris Lu"
|
LABEL author="Chris Lu"
|
||||||
COPY --from=builder /go/bin/weed /usr/bin/
|
COPY --from=builder /go/bin/weed /usr/bin/
|
||||||
RUN mkdir -p /etc/seaweedfs
|
RUN mkdir -p /etc/seaweedfs
|
||||||
COPY --from=builder /go/src/github.com/chrislusf/seaweedfs/docker/filer.toml /etc/seaweedfs/filer.toml
|
COPY --from=builder /go/src/github.com/chrislusf/seaweedfs/docker/filer_rocksdb.toml /etc/seaweedfs/filer.toml
|
||||||
COPY --from=builder /go/src/github.com/chrislusf/seaweedfs/docker/entrypoint.sh /entrypoint.sh
|
COPY --from=builder /go/src/github.com/chrislusf/seaweedfs/docker/entrypoint.sh /entrypoint.sh
|
||||||
RUN apk add fuse snappy gflags
|
RUN apk add fuse snappy gflags
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ EXPOSE 8333
|
|||||||
# webdav server http port
|
# webdav server http port
|
||||||
EXPOSE 7333
|
EXPOSE 7333
|
||||||
|
|
||||||
RUN mkdir -p /data/filerldb2
|
RUN mkdir -p /data/filer_rocksdb
|
||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[rocksdb]
|
||||||
|
enabled = true
|
||||||
|
dir = "/data/filer_rocksdb"
|
||||||
@@ -8,7 +8,6 @@ require (
|
|||||||
cloud.google.com/go/storage v1.16.1
|
cloud.google.com/go/storage v1.16.1
|
||||||
github.com/Azure/azure-pipeline-go v0.2.3
|
github.com/Azure/azure-pipeline-go v0.2.3
|
||||||
github.com/Azure/azure-storage-blob-go v0.14.0
|
github.com/Azure/azure-storage-blob-go v0.14.0
|
||||||
github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798 // indirect
|
|
||||||
github.com/OneOfOne/xxhash v1.2.2
|
github.com/OneOfOne/xxhash v1.2.2
|
||||||
github.com/Shopify/sarama v1.23.1
|
github.com/Shopify/sarama v1.23.1
|
||||||
github.com/aws/aws-sdk-go v1.35.3
|
github.com/aws/aws-sdk-go v1.35.3
|
||||||
@@ -163,20 +162,22 @@ require (
|
|||||||
modernc.org/token v1.0.0 // indirect
|
modernc.org/token v1.0.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/fluent/fluent-logger-golang v1.8.0
|
||||||
|
github.com/hanwen/go-fuse/v2 v2.1.0
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.google.com/go/kms v1.0.0 // indirect
|
cloud.google.com/go/kms v1.0.0 // indirect
|
||||||
github.com/apache/thrift v0.15.0 // indirect
|
github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798 // indirect
|
||||||
github.com/d4l3k/messagediff v1.2.1 // indirect
|
github.com/d4l3k/messagediff v1.2.1 // indirect
|
||||||
github.com/fluent/fluent-logger-golang v1.8.0 // indirect
|
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/gorilla/websocket v1.4.2 // indirect
|
|
||||||
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
|
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
|
||||||
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
|
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
|
||||||
github.com/jcmturner/goidentity/v6 v6.0.1 // indirect
|
github.com/jcmturner/goidentity/v6 v6.0.1 // indirect
|
||||||
github.com/jcmturner/rpc/v2 v2.0.2 // indirect
|
github.com/jcmturner/rpc/v2 v2.0.2 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.7 // indirect
|
github.com/mattn/go-runewidth v0.0.7 // indirect
|
||||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible // indirect
|
github.com/mattn/go-sqlite3 v2.0.1+incompatible // indirect
|
||||||
github.com/miekg/dns v1.1.44 // indirect
|
|
||||||
github.com/philhofer/fwd v1.1.1 // indirect
|
github.com/philhofer/fwd v1.1.1 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/tinylib/msgp v1.1.6 // indirect
|
github.com/tinylib/msgp v1.1.6 // indirect
|
||||||
|
|||||||
@@ -124,8 +124,6 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5
|
|||||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||||
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||||
github.com/apache/thrift v0.15.0 h1:aGvdaR0v1t9XLgjtBYwxcBvBOTMqClzwE26CHOgjW1Y=
|
|
||||||
github.com/apache/thrift v0.15.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU=
|
|
||||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||||
@@ -281,30 +279,6 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
|||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/go-zookeeper/zk v1.0.2 h1:4mx0EYENAdX/B/rbunjlt5+4RTA/a9SMHBRuSKdGxPM=
|
github.com/go-zookeeper/zk v1.0.2 h1:4mx0EYENAdX/B/rbunjlt5+4RTA/a9SMHBRuSKdGxPM=
|
||||||
github.com/go-zookeeper/zk v1.0.2/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw=
|
github.com/go-zookeeper/zk v1.0.2/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw=
|
||||||
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
|
|
||||||
github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
|
|
||||||
github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg=
|
|
||||||
github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
|
||||||
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
|
||||||
github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs=
|
|
||||||
github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
|
|
||||||
github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
|
|
||||||
github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk=
|
|
||||||
github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28=
|
|
||||||
github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo=
|
|
||||||
github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk=
|
|
||||||
github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw=
|
|
||||||
github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360=
|
|
||||||
github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg=
|
|
||||||
github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE=
|
|
||||||
github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8=
|
|
||||||
github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
|
|
||||||
github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
|
|
||||||
github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
|
|
||||||
github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
|
|
||||||
github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ=
|
|
||||||
github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0=
|
|
||||||
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
|
|
||||||
github.com/gocql/gocql v0.0.0-20210707082121-9a3953d1826d h1:k544nNVphXK4Yt0FTduvOvCfJabEY/DMkdNw0zpCwBE=
|
github.com/gocql/gocql v0.0.0-20210707082121-9a3953d1826d h1:k544nNVphXK4Yt0FTduvOvCfJabEY/DMkdNw0zpCwBE=
|
||||||
github.com/gocql/gocql v0.0.0-20210707082121-9a3953d1826d/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
|
github.com/gocql/gocql v0.0.0-20210707082121-9a3953d1826d/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
|
||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
@@ -431,8 +405,6 @@ github.com/gorilla/sessions v1.2.0 h1:S7P+1Hm5V/AT9cjEcUD5uDaQSX0OE577aCXgoaKpYb
|
|||||||
github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 h1:THDBEeQ9xZ8JEaCLyLQqXMMdRqNr0QAUJTIkQAUtFjg=
|
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 h1:THDBEeQ9xZ8JEaCLyLQqXMMdRqNr0QAUJTIkQAUtFjg=
|
||||||
@@ -443,6 +415,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
|
|||||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
||||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
||||||
|
github.com/hanwen/go-fuse v1.0.0 h1:GxS9Zrn6c35/BnfiVsZVWmsG803xwE7eVRDvcf/BEVc=
|
||||||
|
github.com/hanwen/go-fuse v1.0.0/go.mod h1:unqXarDXqzAk0rt98O2tVndEPIpUgLD9+rwFisZH3Ok=
|
||||||
|
github.com/hanwen/go-fuse/v2 v2.1.0 h1:+32ffteETaLYClUj0a3aHjZ1hOPxxaNEHiZiujuDaek=
|
||||||
|
github.com/hanwen/go-fuse/v2 v2.1.0/go.mod h1:oRyA5eK+pvJyv5otpO/DgccS8y/RvYMaO00GgRLGryc=
|
||||||
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
|
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
|
||||||
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||||
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
|
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
|
||||||
@@ -516,16 +492,11 @@ github.com/karlseguin/ccache/v2 v2.0.7 h1:y5Pfi4eiyYCOD6LS/Kj+o6Nb4M5Ngpw9qFQs+v
|
|||||||
github.com/karlseguin/ccache/v2 v2.0.7/go.mod h1:2BDThcfQMf/c0jnZowt16eW405XIqZPavt+HoYEtcxQ=
|
github.com/karlseguin/ccache/v2 v2.0.7/go.mod h1:2BDThcfQMf/c0jnZowt16eW405XIqZPavt+HoYEtcxQ=
|
||||||
github.com/karlseguin/expect v1.0.2-0.20190806010014-778a5f0c6003 h1:vJ0Snvo+SLMY72r5J4sEfkuE7AFbixEP2qRbEcum/wA=
|
github.com/karlseguin/expect v1.0.2-0.20190806010014-778a5f0c6003 h1:vJ0Snvo+SLMY72r5J4sEfkuE7AFbixEP2qRbEcum/wA=
|
||||||
github.com/karlseguin/expect v1.0.2-0.20190806010014-778a5f0c6003/go.mod h1:zNBxMY8P21owkeogJELCLeHIt+voOSduHYTFUbwRAV8=
|
github.com/karlseguin/expect v1.0.2-0.20190806010014-778a5f0c6003/go.mod h1:zNBxMY8P21owkeogJELCLeHIt+voOSduHYTFUbwRAV8=
|
||||||
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
|
|
||||||
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
|
|
||||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
|
||||||
github.com/klauspost/compress v1.10.9 h1:pPRt1Z78crspaHISkpSSHjDlx+Tt9suHe519dsI0vF4=
|
|
||||||
github.com/klauspost/compress v1.10.9/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
|
||||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||||
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
|
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
|
||||||
@@ -533,7 +504,6 @@ github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgo
|
|||||||
github.com/klauspost/reedsolomon v1.9.2 h1:E9CMS2Pqbv+C7tsrYad4YC9MfhnMVWhMRsTi7U0UB18=
|
github.com/klauspost/reedsolomon v1.9.2 h1:E9CMS2Pqbv+C7tsrYad4YC9MfhnMVWhMRsTi7U0UB18=
|
||||||
github.com/klauspost/reedsolomon v1.9.2/go.mod h1:CwCi+NUr9pqSVktrkN+Ondf06rkhYZ/pcNv7fu+8Un4=
|
github.com/klauspost/reedsolomon v1.9.2/go.mod h1:CwCi+NUr9pqSVktrkN+Ondf06rkhYZ/pcNv7fu+8Un4=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||||
@@ -546,6 +516,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
|||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/kurin/blazer v0.5.3 h1:SAgYv0TKU0kN/ETfO5ExjNAPyMt2FocO2s/UlCHfjAk=
|
github.com/kurin/blazer v0.5.3 h1:SAgYv0TKU0kN/ETfO5ExjNAPyMt2FocO2s/UlCHfjAk=
|
||||||
github.com/kurin/blazer v0.5.3/go.mod h1:4FCXMUWo9DllR2Do4TtBd377ezyAJ51vB5uTBjt0pGU=
|
github.com/kurin/blazer v0.5.3/go.mod h1:4FCXMUWo9DllR2Do4TtBd377ezyAJ51vB5uTBjt0pGU=
|
||||||
|
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
|
||||||
|
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E=
|
github.com/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E=
|
||||||
github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
@@ -559,8 +531,6 @@ github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzR
|
|||||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8=
|
github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8=
|
||||||
github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||||
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
|
|
||||||
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
|
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
|
github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
|
||||||
github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
|
github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
|
||||||
@@ -580,8 +550,6 @@ github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW
|
|||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||||
github.com/miekg/dns v1.1.44 h1:4rpqcegYPVkvIeVhITrKP1sRR3KjfRc1nrOPMUZmLyc=
|
|
||||||
github.com/miekg/dns v1.1.44/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
|
|
||||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
@@ -721,17 +689,11 @@ github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6O
|
|||||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||||
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
|
||||||
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||||
github.com/seaweedfs/fuse v1.2.0 h1:m4Ar3I0TY/Tzyb80lfJiXUKFcMBHqA5e/cZwxQtilZo=
|
|
||||||
github.com/seaweedfs/fuse v1.2.0/go.mod h1:iwbDQv5BZACY54r6AO/6xsLNuMaYcBKSkLTZVfmK594=
|
|
||||||
github.com/seaweedfs/fuse v1.2.1 h1:920YH3+PnIqpNLo2lsZDTUJHUPLXnxgQGEXoVb/yMno=
|
|
||||||
github.com/seaweedfs/fuse v1.2.1/go.mod h1:iwbDQv5BZACY54r6AO/6xsLNuMaYcBKSkLTZVfmK594=
|
|
||||||
github.com/seaweedfs/fuse v1.2.2 h1:01l8OjIdyATRNqVc/gDPgFobuC8ubQF3hRKOPColROw=
|
github.com/seaweedfs/fuse v1.2.2 h1:01l8OjIdyATRNqVc/gDPgFobuC8ubQF3hRKOPColROw=
|
||||||
github.com/seaweedfs/fuse v1.2.2/go.mod h1:iwbDQv5BZACY54r6AO/6xsLNuMaYcBKSkLTZVfmK594=
|
github.com/seaweedfs/fuse v1.2.2/go.mod h1:iwbDQv5BZACY54r6AO/6xsLNuMaYcBKSkLTZVfmK594=
|
||||||
github.com/seaweedfs/goexif v1.0.2 h1:p+rTXYdQ2mgxd+1JaTrQ9N8DvYuw9UH9xgYmJ+Bb29E=
|
github.com/seaweedfs/goexif v1.0.2 h1:p+rTXYdQ2mgxd+1JaTrQ9N8DvYuw9UH9xgYmJ+Bb29E=
|
||||||
@@ -740,8 +702,6 @@ github.com/secsy/goftp v0.0.0-20190720192957-f31499d7c79a h1:C6IhVTxNkhlb0tlCB6J
|
|||||||
github.com/secsy/goftp v0.0.0-20190720192957-f31499d7c79a/go.mod h1:MnkX001NG75g3p8bhFycnyIjeQoOjGL6CEIsdE/nKSY=
|
github.com/secsy/goftp v0.0.0-20190720192957-f31499d7c79a/go.mod h1:MnkX001NG75g3p8bhFycnyIjeQoOjGL6CEIsdE/nKSY=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
|
||||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo=
|
github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo=
|
||||||
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
|
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
|
||||||
@@ -792,17 +752,11 @@ github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203 h1:QVqDTf3h2WHt08Yu
|
|||||||
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKNihBbwlX8dLpwxCl3+HnXKV/R0e+sRLd9C8=
|
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKNihBbwlX8dLpwxCl3+HnXKV/R0e+sRLd9C8=
|
||||||
github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965 h1:1oFLiOyVl+W7bnBzGhf7BbIv9loSFQcieWWYIjLqcAw=
|
github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965 h1:1oFLiOyVl+W7bnBzGhf7BbIv9loSFQcieWWYIjLqcAw=
|
||||||
github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA=
|
github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA=
|
||||||
github.com/tidwall/gjson v1.8.1 h1:8j5EE9Hrh3l9Od1OIEDAb7IpezNA20UdRngNAj5N0WU=
|
|
||||||
github.com/tidwall/gjson v1.8.1/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
|
|
||||||
github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo=
|
github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo=
|
||||||
github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE=
|
|
||||||
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
|
||||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
github.com/tidwall/pretty v1.1.0 h1:K3hMW5epkdAVwibsQEfR/7Zj0Qgt4DxtNumTq/VloO8=
|
|
||||||
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
|
||||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw=
|
github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw=
|
||||||
@@ -853,8 +807,6 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.0 h1:2aQv6F436YnN7I4VbI8PPYrBhu+SmrTaADcf8Mi/
|
|||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
||||||
go.etcd.io/etcd/client/v3 v3.5.0 h1:62Eh0XOro+rDwkrypAGDfgmNh5Joq+z+W9HZdlXMzek=
|
go.etcd.io/etcd/client/v3 v3.5.0 h1:62Eh0XOro+rDwkrypAGDfgmNh5Joq+z+W9HZdlXMzek=
|
||||||
go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0=
|
go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0=
|
||||||
go.mongodb.org/mongo-driver v1.7.0 h1:hHrvOBWlWB2c7+8Gh/Xi5jj82AgidK/t7KVXBZ+IyUA=
|
|
||||||
go.mongodb.org/mongo-driver v1.7.0/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8=
|
|
||||||
go.mongodb.org/mongo-driver v1.8.0 h1:R/P/JJzu8LJvJ1lDfph9GLNIKQxEtIHFfnUUUve35zY=
|
go.mongodb.org/mongo-driver v1.8.0 h1:R/P/JJzu8LJvJ1lDfph9GLNIKQxEtIHFfnUUUve35zY=
|
||||||
go.mongodb.org/mongo-driver v1.8.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
|
go.mongodb.org/mongo-driver v1.8.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
|
||||||
go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0=
|
go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0=
|
||||||
@@ -898,7 +850,6 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf
|
|||||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||||
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
@@ -907,7 +858,6 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U
|
|||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
@@ -1003,7 +953,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
|||||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||||
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c=
|
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c=
|
||||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
@@ -1027,7 +976,6 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ
|
|||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@@ -1048,11 +996,9 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@@ -1112,10 +1058,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210817142637-7d9622a276b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210817142637-7d9622a276b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365 h1:6wSTsvPddg9gc/mVEEyk9oOAoxn+bT4Z9q1zx+4RwA4=
|
|
||||||
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 h1:0jf+tOCoZ3LyutmCOWpVni1chK4VfFLhRsDK7MhqGRY=
|
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 h1:0jf+tOCoZ3LyutmCOWpVni1chK4VfFLhRsDK7MhqGRY=
|
||||||
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
@@ -1127,7 +1070,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
|||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
@@ -1144,9 +1086,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3
|
|||||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
@@ -1205,7 +1144,6 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
|||||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
|
|
||||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2 h1:BonxutuHCTL0rBDnZlKjpGIQFTjyUVTexFOdWkB6Fg0=
|
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2 h1:BonxutuHCTL0rBDnZlKjpGIQFTjyUVTexFOdWkB6Fg0=
|
||||||
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
description: SeaweedFS
|
description: SeaweedFS
|
||||||
name: seaweedfs
|
name: seaweedfs
|
||||||
appVersion: "2.86"
|
appVersion: "2.88"
|
||||||
version: "2.86"
|
version: "2.88"
|
||||||
@@ -40,7 +40,7 @@ spec:
|
|||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: {{ .Values.global.imagePullSecrets }}
|
- name: {{ .Values.global.imagePullSecrets }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
terminationGracePeriodSeconds: 10
|
terminationGracePeriodSeconds: 150
|
||||||
{{- if .Values.volume.priorityClassName }}
|
{{- if .Values.volume.priorityClassName }}
|
||||||
priorityClassName: {{ .Values.volume.priorityClassName | quote }}
|
priorityClassName: {{ .Values.volume.priorityClassName | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ message Entry {
|
|||||||
bytes content = 9; // if not empty, the file content
|
bytes content = 9; // if not empty, the file content
|
||||||
|
|
||||||
RemoteEntry remote_entry = 10;
|
RemoteEntry remote_entry = 10;
|
||||||
|
int64 quota = 11; // for bucket only. Positive/Negative means enabled/disabled.
|
||||||
}
|
}
|
||||||
|
|
||||||
message FullEntry {
|
message FullEntry {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.hadoop</groupId>
|
<groupId>org.apache.hadoop</groupId>
|
||||||
<artifactId>hadoop-common</artifactId>
|
<artifactId>hadoop-common</artifactId>
|
||||||
<version>2.9.2</version>
|
<version>2.10.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.hadoop</groupId>
|
<groupId>org.apache.hadoop</groupId>
|
||||||
<artifactId>hadoop-common</artifactId>
|
<artifactId>hadoop-common</artifactId>
|
||||||
<version>3.2.1</version>
|
<version>3.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.hadoop</groupId>
|
<groupId>org.apache.hadoop</groupId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<seaweedfs.client.version>2.85</seaweedfs.client.version>
|
<seaweedfs.client.version>2.85</seaweedfs.client.version>
|
||||||
<hadoop.version>2.9.2</hadoop.version>
|
<hadoop.version>2.10.1</hadoop.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<groupId>com.github.chrislusf</groupId>
|
<groupId>com.github.chrislusf</groupId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<seaweedfs.client.version>2.85</seaweedfs.client.version>
|
<seaweedfs.client.version>2.85</seaweedfs.client.version>
|
||||||
<hadoop.version>3.1.1</hadoop.version>
|
<hadoop.version>3.1.4</hadoop.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<groupId>com.github.chrislusf</groupId>
|
<groupId>com.github.chrislusf</groupId>
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ debug_mount:
|
|||||||
go build -gcflags="all=-N -l"
|
go build -gcflags="all=-N -l"
|
||||||
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec weed -- -v=4 mount -dir=~/tmp/mm -cacheCapacityMB=0 -filer.path=/ -umask=000
|
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec weed -- -v=4 mount -dir=~/tmp/mm -cacheCapacityMB=0 -filer.path=/ -umask=000
|
||||||
|
|
||||||
|
debug_mount2:
|
||||||
|
go build -gcflags="all=-N -l"
|
||||||
|
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec weed -- -v=4 mount2 -dir=~/tmp/mm -cacheCapacityMB=0 -filer.path=/ -umask=000
|
||||||
|
|
||||||
debug_server:
|
debug_server:
|
||||||
go build -gcflags="all=-N -l"
|
go build -gcflags="all=-N -l"
|
||||||
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec weed -- server -dir=~/tmp/99 -filer -volume.port=8343 -s3 -volume.max=0 -master.volumeSizeLimitMB=1024 -volume.preStopSeconds=1
|
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec weed -- server -dir=~/tmp/99 -filer -volume.port=8343 -s3 -volume.max=0 -master.volumeSizeLimitMB=1024 -volume.preStopSeconds=1
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ var Commands = []*Command{
|
|||||||
cmdMaster,
|
cmdMaster,
|
||||||
cmdMasterFollower,
|
cmdMasterFollower,
|
||||||
cmdMount,
|
cmdMount,
|
||||||
|
cmdMount2,
|
||||||
cmdS3,
|
cmdS3,
|
||||||
cmdIam,
|
cmdIam,
|
||||||
cmdMsgBroker,
|
cmdMsgBroker,
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"math"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -115,7 +114,7 @@ func runFilerCat(cmd *Command, args []string) bool {
|
|||||||
|
|
||||||
filerCat.filerClient = client
|
filerCat.filerClient = client
|
||||||
|
|
||||||
return filer.StreamContent(&filerCat, writer, respLookupEntry.Entry.Chunks, 0, math.MaxInt64)
|
return filer.StreamContent(&filerCat, writer, respLookupEntry.Entry.Chunks, 0, int64(filer.FileSize(respLookupEntry.Entry)))
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ func genFileCopyTask(fileOrDir string, destPath string, fileCopyTaskChan chan Fi
|
|||||||
if mode.IsDir() {
|
if mode.IsDir() {
|
||||||
files, _ := os.ReadDir(fileOrDir)
|
files, _ := os.ReadDir(fileOrDir)
|
||||||
for _, subFileOrDir := range files {
|
for _, subFileOrDir := range files {
|
||||||
cleanedDestDirectory := filepath.Clean(destPath + fi.Name())
|
cleanedDestDirectory := destPath + fi.Name()
|
||||||
if err = genFileCopyTask(fileOrDir+"/"+subFileOrDir.Name(), cleanedDestDirectory+"/", fileCopyTaskChan); err != nil {
|
if err = genFileCopyTask(fileOrDir+"/"+subFileOrDir.Name(), cleanedDestDirectory+"/", fileCopyTaskChan); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ func (option *RemoteGatewayOptions) makeBucketedEventProcessor(filerSource *sour
|
|||||||
// update directory property
|
// update directory property
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if filer.IsSameData(message.OldEntry, message.NewEntry) {
|
if message.OldEntry.RemoteEntry != nil && filer.IsSameData(message.OldEntry, message.NewEntry) {
|
||||||
glog.V(2).Infof("update meta: %+v", resp)
|
glog.V(2).Infof("update meta: %+v", resp)
|
||||||
oldDest := toRemoteStorageLocation(oldBucket, util.NewFullPath(resp.Directory, message.OldEntry.Name), oldRemoteStorageMountLocation)
|
oldDest := toRemoteStorageLocation(oldBucket, util.NewFullPath(resp.Directory, message.OldEntry.Name), oldRemoteStorageMountLocation)
|
||||||
return client.UpdateFileMetadata(oldDest, message.OldEntry, message.NewEntry)
|
return client.UpdateFileMetadata(oldDest, message.OldEntry, message.NewEntry)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package command
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/chrislusf/raft/protobuf"
|
"github.com/chrislusf/raft/protobuf"
|
||||||
|
stats_collect "github.com/chrislusf/seaweedfs/weed/stats"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"google.golang.org/grpc/reflection"
|
"google.golang.org/grpc/reflection"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -42,6 +43,7 @@ type MasterOptions struct {
|
|||||||
metricsAddress *string
|
metricsAddress *string
|
||||||
metricsIntervalSec *int
|
metricsIntervalSec *int
|
||||||
raftResumeState *bool
|
raftResumeState *bool
|
||||||
|
metricsHttpPort *int
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -61,6 +63,7 @@ func init() {
|
|||||||
m.disableHttp = cmdMaster.Flag.Bool("disableHttp", false, "disable http requests, only gRPC operations are allowed.")
|
m.disableHttp = cmdMaster.Flag.Bool("disableHttp", false, "disable http requests, only gRPC operations are allowed.")
|
||||||
m.metricsAddress = cmdMaster.Flag.String("metrics.address", "", "Prometheus gateway address <host>:<port>")
|
m.metricsAddress = cmdMaster.Flag.String("metrics.address", "", "Prometheus gateway address <host>:<port>")
|
||||||
m.metricsIntervalSec = cmdMaster.Flag.Int("metrics.intervalSeconds", 15, "Prometheus push interval in seconds")
|
m.metricsIntervalSec = cmdMaster.Flag.Int("metrics.intervalSeconds", 15, "Prometheus push interval in seconds")
|
||||||
|
m.metricsHttpPort = cmdMaster.Flag.Int("metricsPort", 0, "Prometheus metrics listen port")
|
||||||
m.raftResumeState = cmdMaster.Flag.Bool("resumeState", false, "resume previous state on start master server")
|
m.raftResumeState = cmdMaster.Flag.Bool("resumeState", false, "resume previous state on start master server")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,6 +107,7 @@ func runMaster(cmd *Command, args []string) bool {
|
|||||||
glog.Fatalf("volumeSizeLimitMB should be smaller than 30000")
|
glog.Fatalf("volumeSizeLimitMB should be smaller than 30000")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go stats_collect.StartMetricsServer(*m.metricsHttpPort)
|
||||||
startMaster(m, masterWhiteList)
|
startMaster(m, masterWhiteList)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Mount2Options struct {
|
||||||
|
filer *string
|
||||||
|
filerMountRootPath *string
|
||||||
|
dir *string
|
||||||
|
dirAutoCreate *bool
|
||||||
|
collection *string
|
||||||
|
replication *string
|
||||||
|
diskType *string
|
||||||
|
ttlSec *int
|
||||||
|
chunkSizeLimitMB *int
|
||||||
|
concurrentWriters *int
|
||||||
|
cacheDir *string
|
||||||
|
cacheSizeMB *int64
|
||||||
|
dataCenter *string
|
||||||
|
allowOthers *bool
|
||||||
|
umaskString *string
|
||||||
|
nonempty *bool
|
||||||
|
volumeServerAccess *string
|
||||||
|
uidMap *string
|
||||||
|
gidMap *string
|
||||||
|
readOnly *bool
|
||||||
|
debug *bool
|
||||||
|
debugPort *int
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
mount2Options Mount2Options
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdMount2.Run = runMount2 // break init cycle
|
||||||
|
mount2Options.filer = cmdMount2.Flag.String("filer", "localhost:8888", "comma-separated weed filer location")
|
||||||
|
mount2Options.filerMountRootPath = cmdMount2.Flag.String("filer.path", "/", "mount this remote path from filer server")
|
||||||
|
mount2Options.dir = cmdMount2.Flag.String("dir", ".", "mount weed filer to this directory")
|
||||||
|
mount2Options.dirAutoCreate = cmdMount2.Flag.Bool("dirAutoCreate", false, "auto create the directory to mount to")
|
||||||
|
mount2Options.collection = cmdMount2.Flag.String("collection", "", "collection to create the files")
|
||||||
|
mount2Options.replication = cmdMount2.Flag.String("replication", "", "replication(e.g. 000, 001) to create to files. If empty, let filer decide.")
|
||||||
|
mount2Options.diskType = cmdMount2.Flag.String("disk", "", "[hdd|ssd|<tag>] hard drive or solid state drive or any tag")
|
||||||
|
mount2Options.ttlSec = cmdMount2.Flag.Int("ttl", 0, "file ttl in seconds")
|
||||||
|
mount2Options.chunkSizeLimitMB = cmdMount2.Flag.Int("chunkSizeLimitMB", 2, "local write buffer size, also chunk large files")
|
||||||
|
mount2Options.concurrentWriters = cmdMount2.Flag.Int("concurrentWriters", 32, "limit concurrent goroutine writers if not 0")
|
||||||
|
mount2Options.cacheDir = cmdMount2.Flag.String("cacheDir", os.TempDir(), "local cache directory for file chunks and meta data")
|
||||||
|
mount2Options.cacheSizeMB = cmdMount2.Flag.Int64("cacheCapacityMB", 1000, "local file chunk cache capacity in MB (0 will disable cache)")
|
||||||
|
mount2Options.dataCenter = cmdMount2.Flag.String("dataCenter", "", "prefer to write to the data center")
|
||||||
|
mount2Options.allowOthers = cmdMount2.Flag.Bool("allowOthers", true, "allows other users to access the file system")
|
||||||
|
mount2Options.umaskString = cmdMount2.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")
|
||||||
|
mount2Options.nonempty = cmdMount2.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")
|
||||||
|
mount2Options.volumeServerAccess = cmdMount2.Flag.String("volumeServerAccess", "direct", "access volume servers by [direct|publicUrl|filerProxy]")
|
||||||
|
mount2Options.uidMap = cmdMount2.Flag.String("map.uid", "", "map local uid to uid on filer, comma-separated <local_uid>:<filer_uid>")
|
||||||
|
mount2Options.gidMap = cmdMount2.Flag.String("map.gid", "", "map local gid to gid on filer, comma-separated <local_gid>:<filer_gid>")
|
||||||
|
mount2Options.readOnly = cmdMount2.Flag.Bool("readOnly", false, "read only")
|
||||||
|
mount2Options.debug = cmdMount2.Flag.Bool("debug", false, "serves runtime profiling data, e.g., http://localhost:<debug.port>/debug/pprof/goroutine?debug=2")
|
||||||
|
mount2Options.debugPort = cmdMount2.Flag.Int("debug.port", 6061, "http port for debugging")
|
||||||
|
|
||||||
|
mountCpuProfile = cmdMount2.Flag.String("cpuprofile", "", "cpu profile output file")
|
||||||
|
mountMemProfile = cmdMount2.Flag.String("memprofile", "", "memory profile output file")
|
||||||
|
mountReadRetryTime = cmdMount2.Flag.Duration("readRetryTime", 6*time.Second, "maximum read retry wait time")
|
||||||
|
}
|
||||||
|
|
||||||
|
var cmdMount2 = &Command{
|
||||||
|
UsageLine: "mount2 -filer=localhost:8888 -dir=/some/dir",
|
||||||
|
Short: "<WIP> mount weed filer to a directory as file system in userspace(FUSE)",
|
||||||
|
Long: `mount weed filer to userspace.
|
||||||
|
|
||||||
|
Pre-requisites:
|
||||||
|
1) have SeaweedFS master and volume servers running
|
||||||
|
2) have a "weed filer" running
|
||||||
|
These 2 requirements can be achieved with one command "weed server -filer=true"
|
||||||
|
|
||||||
|
This uses github.com/seaweedfs/fuse, which enables writing FUSE file systems on
|
||||||
|
Linux, and OS X.
|
||||||
|
|
||||||
|
On OS X, it requires OSXFUSE (http://osxfuse.github.com/).
|
||||||
|
|
||||||
|
`,
|
||||||
|
}
|
||||||
@@ -0,0 +1,210 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/mount"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/mount/meta_cache"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/mount/unmount"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/security"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
"runtime"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util/grace"
|
||||||
|
)
|
||||||
|
|
||||||
|
func runMount2(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
|
if *mountOptions.debug {
|
||||||
|
go http.ListenAndServe(fmt.Sprintf(":%d", *mountOptions.debugPort), nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
grace.SetupProfiling(*mountCpuProfile, *mountMemProfile)
|
||||||
|
if *mountReadRetryTime < time.Second {
|
||||||
|
*mountReadRetryTime = time.Second
|
||||||
|
}
|
||||||
|
util.RetryWaitTime = *mountReadRetryTime
|
||||||
|
|
||||||
|
umask, umaskErr := strconv.ParseUint(*mountOptions.umaskString, 8, 64)
|
||||||
|
if umaskErr != nil {
|
||||||
|
fmt.Printf("can not parse umask %s", *mountOptions.umaskString)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) > 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return RunMount2(&mount2Options, os.FileMode(umask))
|
||||||
|
}
|
||||||
|
|
||||||
|
func RunMount2(option *Mount2Options, umask os.FileMode) bool {
|
||||||
|
|
||||||
|
// basic checks
|
||||||
|
chunkSizeLimitMB := *mountOptions.chunkSizeLimitMB
|
||||||
|
if chunkSizeLimitMB <= 0 {
|
||||||
|
fmt.Printf("Please specify a reasonable buffer size.")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to connect to filer
|
||||||
|
filerAddresses := pb.ServerAddresses(*option.filer).ToAddresses()
|
||||||
|
util.LoadConfiguration("security", false)
|
||||||
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
var cipher bool
|
||||||
|
var err error
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
err = pb.WithOneOfGrpcFilerClients(false, filerAddresses, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("get filer grpc address %v configuration: %v", filerAddresses, err)
|
||||||
|
}
|
||||||
|
cipher = resp.Cipher
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("failed to talk to filer %v: %v", filerAddresses, err)
|
||||||
|
glog.V(0).Infof("wait for %d seconds ...", i+1)
|
||||||
|
time.Sleep(time.Duration(i+1) * time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("failed to talk to filer %v: %v", filerAddresses, err)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
filerMountRootPath := *option.filerMountRootPath
|
||||||
|
|
||||||
|
// clean up mount point
|
||||||
|
dir := util.ResolvePath(*option.dir)
|
||||||
|
if dir == "" {
|
||||||
|
fmt.Printf("Please specify the mount directory via \"-dir\"")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
unmount.Unmount(dir)
|
||||||
|
|
||||||
|
// detect mount folder mode
|
||||||
|
if *option.dirAutoCreate {
|
||||||
|
os.MkdirAll(dir, os.FileMode(0777)&^umask)
|
||||||
|
}
|
||||||
|
fileInfo, err := os.Stat(dir)
|
||||||
|
|
||||||
|
// collect uid, gid
|
||||||
|
uid, gid := uint32(0), uint32(0)
|
||||||
|
mountMode := os.ModeDir | 0777
|
||||||
|
if err == nil {
|
||||||
|
mountMode = os.ModeDir | os.FileMode(0777)&^umask
|
||||||
|
uid, gid = util.GetFileUidGid(fileInfo)
|
||||||
|
fmt.Printf("mount point owner uid=%d gid=%d mode=%s\n", uid, gid, mountMode)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("can not stat %s\n", dir)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// detect uid, gid
|
||||||
|
if uid == 0 {
|
||||||
|
if u, err := user.Current(); err == nil {
|
||||||
|
if parsedId, pe := strconv.ParseUint(u.Uid, 10, 32); pe == nil {
|
||||||
|
uid = uint32(parsedId)
|
||||||
|
}
|
||||||
|
if parsedId, pe := strconv.ParseUint(u.Gid, 10, 32); pe == nil {
|
||||||
|
gid = uint32(parsedId)
|
||||||
|
}
|
||||||
|
fmt.Printf("current uid=%d gid=%d\n", uid, gid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mapping uid, gid
|
||||||
|
uidGidMapper, err := meta_cache.NewUidGidMapper(*option.uidMap, *option.gidMap)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("failed to parse %s %s: %v\n", *option.uidMap, *option.gidMap, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure target mount point availability
|
||||||
|
if isValid := checkMountPointAvailable(dir); !isValid {
|
||||||
|
glog.Fatalf("Expected mount to still be active, target mount point: %s, please check!", dir)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// mount fuse
|
||||||
|
fuseMountOptions := &fuse.MountOptions{
|
||||||
|
AllowOther: *option.allowOthers,
|
||||||
|
Options: nil,
|
||||||
|
MaxBackground: 128,
|
||||||
|
MaxWrite: 1024 * 1024 * 2,
|
||||||
|
MaxReadAhead: 1024 * 1024 * 2,
|
||||||
|
IgnoreSecurityLabels: false,
|
||||||
|
RememberInodes: false,
|
||||||
|
FsName: *option.filer + ":" + filerMountRootPath,
|
||||||
|
Name: "seaweedfs",
|
||||||
|
SingleThreaded: false,
|
||||||
|
DisableXAttrs: false,
|
||||||
|
Debug: true,
|
||||||
|
EnableLocks: false,
|
||||||
|
ExplicitDataCacheControl: false,
|
||||||
|
// SyncRead: false, // set to false to enable the FUSE_CAP_ASYNC_READ capability
|
||||||
|
DirectMount: true,
|
||||||
|
DirectMountFlags: 0,
|
||||||
|
// EnableAcl: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
// find mount point
|
||||||
|
mountRoot := filerMountRootPath
|
||||||
|
if mountRoot != "/" && strings.HasSuffix(mountRoot, "/") {
|
||||||
|
mountRoot = mountRoot[0 : len(mountRoot)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
seaweedFileSystem := mount.NewSeaweedFileSystem(&mount.Option{
|
||||||
|
MountDirectory: dir,
|
||||||
|
FilerAddresses: filerAddresses,
|
||||||
|
GrpcDialOption: grpcDialOption,
|
||||||
|
FilerMountRootPath: mountRoot,
|
||||||
|
Collection: *option.collection,
|
||||||
|
Replication: *option.replication,
|
||||||
|
TtlSec: int32(*option.ttlSec),
|
||||||
|
DiskType: types.ToDiskType(*option.diskType),
|
||||||
|
ChunkSizeLimit: int64(chunkSizeLimitMB) * 1024 * 1024,
|
||||||
|
ConcurrentWriters: *option.concurrentWriters,
|
||||||
|
CacheDir: *option.cacheDir,
|
||||||
|
CacheSizeMB: *option.cacheSizeMB,
|
||||||
|
DataCenter: *option.dataCenter,
|
||||||
|
MountUid: uid,
|
||||||
|
MountGid: gid,
|
||||||
|
MountMode: mountMode,
|
||||||
|
MountCtime: fileInfo.ModTime(),
|
||||||
|
MountMtime: time.Now(),
|
||||||
|
Umask: umask,
|
||||||
|
VolumeServerAccess: *mountOptions.volumeServerAccess,
|
||||||
|
Cipher: cipher,
|
||||||
|
UidGidMapper: uidGidMapper,
|
||||||
|
})
|
||||||
|
|
||||||
|
server, err := fuse.NewServer(seaweedFileSystem, dir, fuseMountOptions)
|
||||||
|
if err != nil {
|
||||||
|
glog.Fatalf("Mount fail: %v", err)
|
||||||
|
}
|
||||||
|
grace.OnInterrupt(func() {
|
||||||
|
unmount.Unmount(dir)
|
||||||
|
})
|
||||||
|
|
||||||
|
seaweedFileSystem.StartBackgroundTasks()
|
||||||
|
|
||||||
|
fmt.Printf("This is SeaweedFS version %s %s %s\n", util.Version(), runtime.GOOS, runtime.GOARCH)
|
||||||
|
|
||||||
|
server.Serve()
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package command
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/command/scaffold"
|
"github.com/chrislusf/seaweedfs/weed/command/scaffold"
|
||||||
@@ -56,7 +56,7 @@ func runScaffold(cmd *Command, args []string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *outputPath != "" {
|
if *outputPath != "" {
|
||||||
os.WriteFile(filepath.Join(*outputPath, *config+".toml"), []byte(content), 0644)
|
util.WriteFile(filepath.Join(*outputPath, *config+".toml"), []byte(content), 0644)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(content)
|
fmt.Println(content)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ type Entry struct {
|
|||||||
HardLinkCounter int32
|
HardLinkCounter int32
|
||||||
Content []byte
|
Content []byte
|
||||||
Remote *filer_pb.RemoteEntry
|
Remote *filer_pb.RemoteEntry
|
||||||
|
Quota int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (entry *Entry) Size() uint64 {
|
func (entry *Entry) Size() uint64 {
|
||||||
@@ -70,6 +71,7 @@ func (entry *Entry) ShallowClone() *Entry {
|
|||||||
newEntry.HardLinkCounter = entry.HardLinkCounter
|
newEntry.HardLinkCounter = entry.HardLinkCounter
|
||||||
newEntry.Content = entry.Content
|
newEntry.Content = entry.Content
|
||||||
newEntry.Remote = entry.Remote
|
newEntry.Remote = entry.Remote
|
||||||
|
newEntry.Quota = entry.Quota
|
||||||
|
|
||||||
return newEntry
|
return newEntry
|
||||||
}
|
}
|
||||||
@@ -96,6 +98,7 @@ func (entry *Entry) ToExistingProtoEntry(message *filer_pb.Entry) {
|
|||||||
message.HardLinkCounter = entry.HardLinkCounter
|
message.HardLinkCounter = entry.HardLinkCounter
|
||||||
message.Content = entry.Content
|
message.Content = entry.Content
|
||||||
message.RemoteEntry = entry.Remote
|
message.RemoteEntry = entry.Remote
|
||||||
|
message.Quota = entry.Quota
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromPbEntryToExistingEntry(message *filer_pb.Entry, fsEntry *Entry) {
|
func FromPbEntryToExistingEntry(message *filer_pb.Entry, fsEntry *Entry) {
|
||||||
@@ -106,6 +109,7 @@ func FromPbEntryToExistingEntry(message *filer_pb.Entry, fsEntry *Entry) {
|
|||||||
fsEntry.HardLinkCounter = message.HardLinkCounter
|
fsEntry.HardLinkCounter = message.HardLinkCounter
|
||||||
fsEntry.Content = message.Content
|
fsEntry.Content = message.Content
|
||||||
fsEntry.Remote = message.RemoteEntry
|
fsEntry.Remote = message.RemoteEntry
|
||||||
|
fsEntry.Quota = message.Quota
|
||||||
}
|
}
|
||||||
|
|
||||||
func (entry *Entry) ToProtoFullEntry() *filer_pb.FullEntry {
|
func (entry *Entry) ToProtoFullEntry() *filer_pb.FullEntry {
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ func EqualEntry(a, b *Entry) bool {
|
|||||||
if !proto.Equal(a.Remote, b.Remote) {
|
if !proto.Equal(a.Remote, b.Remote) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if a.Quota != b.Quota {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,21 @@ func DoMinusChunks(as, bs []*filer_pb.FileChunk) (delta []*filer_pb.FileChunk) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DoMinusChunksBySourceFileId(as, bs []*filer_pb.FileChunk) (delta []*filer_pb.FileChunk) {
|
||||||
|
|
||||||
|
fileIds := make(map[string]bool)
|
||||||
|
for _, interval := range bs {
|
||||||
|
fileIds[interval.GetFileIdString()] = true
|
||||||
|
}
|
||||||
|
for _, chunk := range as {
|
||||||
|
if _, found := fileIds[chunk.GetSourceFileId()]; !found {
|
||||||
|
delta = append(delta, chunk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
type ChunkView struct {
|
type ChunkView struct {
|
||||||
FileId string
|
FileId string
|
||||||
Offset int64
|
Offset int64
|
||||||
|
|||||||
@@ -75,12 +75,12 @@ func (fc *FilerConf) loadFromFiler(filer *Filer) (err error) {
|
|||||||
return fc.LoadFromBytes(entry.Content)
|
return fc.LoadFromBytes(entry.Content)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fc.loadFromChunks(filer, entry.Content, entry.Chunks)
|
return fc.loadFromChunks(filer, entry.Content, entry.Chunks, entry.Size())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fc *FilerConf) loadFromChunks(filer *Filer, content []byte, chunks []*filer_pb.FileChunk) (err error) {
|
func (fc *FilerConf) loadFromChunks(filer *Filer, content []byte, chunks []*filer_pb.FileChunk, size uint64) (err error) {
|
||||||
if len(content) == 0 {
|
if len(content) == 0 {
|
||||||
content, err = filer.readEntry(chunks)
|
content, err = filer.readEntry(chunks, size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("read filer conf content: %v", err)
|
glog.Errorf("read filer conf content: %v", err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package filer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"math"
|
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
@@ -55,9 +53,9 @@ func (f *Filer) maybeReloadFilerConfiguration(event *filer_pb.SubscribeMetadataR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Filer) readEntry(chunks []*filer_pb.FileChunk) ([]byte, error) {
|
func (f *Filer) readEntry(chunks []*filer_pb.FileChunk, size uint64) ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
err := StreamContent(f.MasterClient, &buf, chunks, 0, math.MaxInt64)
|
err := StreamContent(f.MasterClient, &buf, chunks, 0, int64(size))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -66,7 +64,7 @@ func (f *Filer) readEntry(chunks []*filer_pb.FileChunk) ([]byte, error) {
|
|||||||
|
|
||||||
func (f *Filer) reloadFilerConfiguration(entry *filer_pb.Entry) {
|
func (f *Filer) reloadFilerConfiguration(entry *filer_pb.Entry) {
|
||||||
fc := NewFilerConf()
|
fc := NewFilerConf()
|
||||||
err := fc.loadFromChunks(f, entry.Content, entry.Chunks)
|
err := fc.loadFromChunks(f, entry.Content, entry.Chunks, FileSize(entry))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("read filer conf chunks: %v", err)
|
glog.Errorf("read filer conf chunks: %v", err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -165,13 +165,14 @@ func (ma *MetaAggregator) subscribeToOneFiler(f *Filer, self pb.ServerAddress, p
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
glog.V(4).Infof("subscribing remote %s meta change: %v", peer, time.Unix(0, lastTsNs))
|
glog.V(4).Infof("subscribing remote %s meta change: %v", peer, time.Unix(0, lastTsNs))
|
||||||
err := pb.WithFilerClient(false, peer, ma.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err := pb.WithFilerClient(true, peer, ma.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
stream, err := client.SubscribeLocalMetadata(ctx, &filer_pb.SubscribeMetadataRequest{
|
stream, err := client.SubscribeLocalMetadata(ctx, &filer_pb.SubscribeMetadataRequest{
|
||||||
ClientName: "filer:" + string(self),
|
ClientName: "filer:" + string(self),
|
||||||
PathPrefix: "/",
|
PathPrefix: "/",
|
||||||
SinceNs: lastTsNs,
|
SinceNs: lastTsNs,
|
||||||
|
ClientId: int32(ma.filer.UniqueFileId),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("subscribe: %v", err)
|
return fmt.Errorf("subscribe: %v", err)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
||||||
"math"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ func ReadEntry(masterClient *wdclient.MasterClient, filerClient filer_pb.Seaweed
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return StreamContent(masterClient, byteBuffer, respLookupEntry.Entry.Chunks, 0, math.MaxInt64)
|
return StreamContent(masterClient, byteBuffer, respLookupEntry.Entry.Chunks, 0, int64(FileSize(respLookupEntry.Entry)))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -491,8 +491,8 @@ func (dir *Dir) removeFolder(entry *filer_pb.Entry, req *fuse.RemoveRequest) err
|
|||||||
dirFullPath := dir.FullPath()
|
dirFullPath := dir.FullPath()
|
||||||
|
|
||||||
glog.V(3).Infof("remove directory entry: %v", req)
|
glog.V(3).Infof("remove directory entry: %v", req)
|
||||||
ignoreRecursiveErr := false // ignore recursion error since the OS should manage it
|
ignoreRecursiveErr := true // ignore recursion error since the OS should manage it
|
||||||
err := filer_pb.Remove(dir.wfs, dirFullPath, req.Name, true, false, ignoreRecursiveErr, false, []int32{dir.wfs.signature})
|
err := filer_pb.Remove(dir.wfs, dirFullPath, req.Name, true, true, ignoreRecursiveErr, false, []int32{dir.wfs.signature})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(0).Infof("remove %s/%s: %v", dirFullPath, req.Name, err)
|
glog.V(0).Infof("remove %s/%s: %v", dirFullPath, req.Name, err)
|
||||||
if strings.Contains(err.Error(), filer.MsgFailDelNonEmptyFolder) {
|
if strings.Contains(err.Error(), filer.MsgFailDelNonEmptyFolder) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MemoryChunkPages struct {
|
type ChunkedDirtyPages struct {
|
||||||
fh *FileHandle
|
fh *FileHandle
|
||||||
writeWaitGroup sync.WaitGroup
|
writeWaitGroup sync.WaitGroup
|
||||||
chunkAddLock sync.Mutex
|
chunkAddLock sync.Mutex
|
||||||
@@ -22,22 +22,21 @@ type MemoryChunkPages struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ = page_writer.DirtyPages(&MemoryChunkPages{})
|
_ = page_writer.DirtyPages(&ChunkedDirtyPages{})
|
||||||
)
|
)
|
||||||
|
|
||||||
func newMemoryChunkPages(fh *FileHandle, chunkSize int64) *MemoryChunkPages {
|
func newMemoryChunkPages(fh *FileHandle, chunkSize int64) *ChunkedDirtyPages {
|
||||||
|
|
||||||
dirtyPages := &MemoryChunkPages{
|
dirtyPages := &ChunkedDirtyPages{
|
||||||
fh: fh,
|
fh: fh,
|
||||||
}
|
}
|
||||||
|
|
||||||
dirtyPages.uploadPipeline = page_writer.NewUploadPipeline(fh.f.fullpath(),
|
dirtyPages.uploadPipeline = page_writer.NewUploadPipeline(fh.f.wfs.concurrentWriters, chunkSize, dirtyPages.saveChunkedFileIntevalToStorage, fh.f.wfs.option.ConcurrentWriters)
|
||||||
fh.f.wfs.concurrentWriters, chunkSize, dirtyPages.saveChunkedFileIntevalToStorage)
|
|
||||||
|
|
||||||
return dirtyPages
|
return dirtyPages
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pages *MemoryChunkPages) AddPage(offset int64, data []byte) {
|
func (pages *ChunkedDirtyPages) AddPage(offset int64, data []byte) {
|
||||||
pages.hasWrites = true
|
pages.hasWrites = true
|
||||||
|
|
||||||
glog.V(4).Infof("%v memory AddPage [%d, %d)", pages.fh.f.fullpath(), offset, offset+int64(len(data)))
|
glog.V(4).Infof("%v memory AddPage [%d, %d)", pages.fh.f.fullpath(), offset, offset+int64(len(data)))
|
||||||
@@ -46,7 +45,7 @@ func (pages *MemoryChunkPages) AddPage(offset int64, data []byte) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pages *MemoryChunkPages) FlushData() error {
|
func (pages *ChunkedDirtyPages) FlushData() error {
|
||||||
if !pages.hasWrites {
|
if !pages.hasWrites {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -57,18 +56,18 @@ func (pages *MemoryChunkPages) FlushData() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pages *MemoryChunkPages) ReadDirtyDataAt(data []byte, startOffset int64) (maxStop int64) {
|
func (pages *ChunkedDirtyPages) ReadDirtyDataAt(data []byte, startOffset int64) (maxStop int64) {
|
||||||
if !pages.hasWrites {
|
if !pages.hasWrites {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return pages.uploadPipeline.MaybeReadDataAt(data, startOffset)
|
return pages.uploadPipeline.MaybeReadDataAt(data, startOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pages *MemoryChunkPages) GetStorageOptions() (collection, replication string) {
|
func (pages *ChunkedDirtyPages) GetStorageOptions() (collection, replication string) {
|
||||||
return pages.collection, pages.replication
|
return pages.collection, pages.replication
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pages *MemoryChunkPages) saveChunkedFileIntevalToStorage(reader io.Reader, offset int64, size int64, cleanupFn func()) {
|
func (pages *ChunkedDirtyPages) saveChunkedFileIntevalToStorage(reader io.Reader, offset int64, size int64, cleanupFn func()) {
|
||||||
|
|
||||||
mtime := time.Now().UnixNano()
|
mtime := time.Now().UnixNano()
|
||||||
defer cleanupFn()
|
defer cleanupFn()
|
||||||
@@ -89,13 +88,13 @@ func (pages *MemoryChunkPages) saveChunkedFileIntevalToStorage(reader io.Reader,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pages MemoryChunkPages) Destroy() {
|
func (pages ChunkedDirtyPages) Destroy() {
|
||||||
pages.uploadPipeline.Shutdown()
|
pages.uploadPipeline.Shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pages *MemoryChunkPages) LockForRead(startOffset, stopOffset int64) {
|
func (pages *ChunkedDirtyPages) LockForRead(startOffset, stopOffset int64) {
|
||||||
pages.uploadPipeline.LockForRead(startOffset, stopOffset)
|
pages.uploadPipeline.LockForRead(startOffset, stopOffset)
|
||||||
}
|
}
|
||||||
func (pages *MemoryChunkPages) UnlockForRead(startOffset, stopOffset int64) {
|
func (pages *ChunkedDirtyPages) UnlockForRead(startOffset, stopOffset int64) {
|
||||||
pages.uploadPipeline.UnlockForRead(startOffset, stopOffset)
|
pages.uploadPipeline.UnlockForRead(startOffset, stopOffset)
|
||||||
}
|
}
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
package filesys
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/filesys/page_writer"
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type TempFileDirtyPages struct {
|
|
||||||
f *File
|
|
||||||
writeWaitGroup sync.WaitGroup
|
|
||||||
pageAddLock sync.Mutex
|
|
||||||
chunkAddLock sync.Mutex
|
|
||||||
lastErr error
|
|
||||||
collection string
|
|
||||||
replication string
|
|
||||||
chunkedFile *page_writer.ChunkedFileWriter
|
|
||||||
}
|
|
||||||
|
|
||||||
func newTempFileDirtyPages(file *File, chunkSize int64) *TempFileDirtyPages {
|
|
||||||
|
|
||||||
tempFile := &TempFileDirtyPages{
|
|
||||||
f: file,
|
|
||||||
chunkedFile: page_writer.NewChunkedFileWriter(file.wfs.option.getTempFilePageDir(), chunkSize),
|
|
||||||
}
|
|
||||||
|
|
||||||
return tempFile
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pages *TempFileDirtyPages) AddPage(offset int64, data []byte) {
|
|
||||||
|
|
||||||
pages.pageAddLock.Lock()
|
|
||||||
defer pages.pageAddLock.Unlock()
|
|
||||||
|
|
||||||
glog.V(4).Infof("%v tempfile AddPage [%d, %d)", pages.f.fullpath(), offset, offset+int64(len(data)))
|
|
||||||
if _, err := pages.chunkedFile.WriteAt(data, offset); err != nil {
|
|
||||||
pages.lastErr = err
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pages *TempFileDirtyPages) FlushData() error {
|
|
||||||
pages.saveChunkedFileToStorage()
|
|
||||||
pages.writeWaitGroup.Wait()
|
|
||||||
if pages.lastErr != nil {
|
|
||||||
return fmt.Errorf("flush data: %v", pages.lastErr)
|
|
||||||
}
|
|
||||||
pages.chunkedFile.Reset()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pages *TempFileDirtyPages) ReadDirtyDataAt(data []byte, startOffset int64) (maxStop int64) {
|
|
||||||
return pages.chunkedFile.ReadDataAt(data, startOffset)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pages *TempFileDirtyPages) GetStorageOptions() (collection, replication string) {
|
|
||||||
return pages.collection, pages.replication
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pages *TempFileDirtyPages) saveChunkedFileToStorage() {
|
|
||||||
|
|
||||||
pages.chunkedFile.ProcessEachInterval(func(file *os.File, logicChunkIndex page_writer.LogicChunkIndex, interval *page_writer.ChunkWrittenInterval) {
|
|
||||||
reader := page_writer.NewFileIntervalReader(pages.chunkedFile, logicChunkIndex, interval)
|
|
||||||
pages.saveChunkedFileIntevalToStorage(reader, int64(logicChunkIndex)*pages.chunkedFile.ChunkSize+interval.StartOffset, interval.Size())
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pages *TempFileDirtyPages) saveChunkedFileIntevalToStorage(reader io.Reader, offset int64, size int64) {
|
|
||||||
|
|
||||||
mtime := time.Now().UnixNano()
|
|
||||||
pages.writeWaitGroup.Add(1)
|
|
||||||
writer := func() {
|
|
||||||
defer pages.writeWaitGroup.Done()
|
|
||||||
|
|
||||||
chunk, collection, replication, err := pages.f.wfs.saveDataAsChunk(pages.f.fullpath())(reader, pages.f.Name, offset)
|
|
||||||
if err != nil {
|
|
||||||
glog.V(0).Infof("%s saveToStorage [%d,%d): %v", pages.f.fullpath(), offset, offset+size, err)
|
|
||||||
pages.lastErr = err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
chunk.Mtime = mtime
|
|
||||||
pages.collection, pages.replication = collection, replication
|
|
||||||
pages.chunkAddLock.Lock()
|
|
||||||
defer pages.chunkAddLock.Unlock()
|
|
||||||
pages.f.addChunks([]*filer_pb.FileChunk{chunk})
|
|
||||||
glog.V(3).Infof("%s saveToStorage %s [%d,%d)", pages.f.fullpath(), chunk.FileId, offset, offset+size)
|
|
||||||
}
|
|
||||||
|
|
||||||
if pages.f.wfs.concurrentWriters != nil {
|
|
||||||
pages.f.wfs.concurrentWriters.Execute(writer)
|
|
||||||
} else {
|
|
||||||
go writer()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pages TempFileDirtyPages) Destroy() {
|
|
||||||
pages.chunkedFile.Reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pages *TempFileDirtyPages) LockForRead(startOffset, stopOffset int64) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pages *TempFileDirtyPages) UnlockForRead(startOffset, stopOffset int64) {
|
|
||||||
}
|
|
||||||
@@ -72,8 +72,8 @@ func (file *File) Attr(ctx context.Context, attr *fuse.Attr) (err error) {
|
|||||||
attr.Mtime = time.Unix(entry.Attributes.Mtime, 0)
|
attr.Mtime = time.Unix(entry.Attributes.Mtime, 0)
|
||||||
attr.Gid = entry.Attributes.Gid
|
attr.Gid = entry.Attributes.Gid
|
||||||
attr.Uid = entry.Attributes.Uid
|
attr.Uid = entry.Attributes.Uid
|
||||||
attr.Blocks = attr.Size/blockSize + 1
|
attr.BlockSize = blockSize
|
||||||
attr.BlockSize = uint32(file.wfs.option.ChunkSizeLimit)
|
attr.Blocks = (attr.Size + blockSize - 1) / blockSize
|
||||||
if entry.HardLinkCounter > 0 {
|
if entry.HardLinkCounter > 0 {
|
||||||
attr.Nlink = uint32(entry.HardLinkCounter)
|
attr.Nlink = uint32(entry.HardLinkCounter)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) {
|
|||||||
reader := fh.reader
|
reader := fh.reader
|
||||||
if reader == nil {
|
if reader == nil {
|
||||||
chunkViews := filer.ViewFromVisibleIntervals(fh.entryViewCache, 0, math.MaxInt64)
|
chunkViews := filer.ViewFromVisibleIntervals(fh.entryViewCache, 0, math.MaxInt64)
|
||||||
glog.V(4).Infof("file handle read %s [%d,%d) from %+v", fileFullPath, offset, offset+int64(len(buff)), chunkViews)
|
glog.V(4).Infof("file handle read %s [%d,%d) from %d views", fileFullPath, offset, offset+int64(len(buff)), len(chunkViews))
|
||||||
for _, chunkView := range chunkViews {
|
for _, chunkView := range chunkViews {
|
||||||
glog.V(4).Infof(" read %s [%d,%d) from chunk %+v", fileFullPath, chunkView.LogicOffset, chunkView.LogicOffset+int64(chunkView.Size), chunkView.FileId)
|
glog.V(4).Infof(" read %s [%d,%d) from chunk %+v", fileFullPath, chunkView.LogicOffset, chunkView.LogicOffset+int64(chunkView.Size), chunkView.FileId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ func (list *ChunkWrittenIntervalList) MarkWritten(startOffset, stopOffset int64)
|
|||||||
func (list *ChunkWrittenIntervalList) IsComplete(chunkSize int64) bool {
|
func (list *ChunkWrittenIntervalList) IsComplete(chunkSize int64) bool {
|
||||||
return list.size() == 1 && list.head.next.isComplete(chunkSize)
|
return list.size() == 1 && list.head.next.isComplete(chunkSize)
|
||||||
}
|
}
|
||||||
|
func (list *ChunkWrittenIntervalList) WrittenSize() (writtenByteCount int64) {
|
||||||
|
for t := list.head; t != nil; t = t.next {
|
||||||
|
writtenByteCount += t.Size()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (list *ChunkWrittenIntervalList) addInterval(interval *ChunkWrittenInterval) {
|
func (list *ChunkWrittenIntervalList) addInterval(interval *ChunkWrittenInterval) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,159 +0,0 @@
|
|||||||
package page_writer
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ActualChunkIndex int
|
|
||||||
|
|
||||||
// ChunkedFileWriter assumes the write requests will come in within chunks
|
|
||||||
type ChunkedFileWriter struct {
|
|
||||||
dir string
|
|
||||||
file *os.File
|
|
||||||
logicToActualChunkIndex map[LogicChunkIndex]ActualChunkIndex
|
|
||||||
chunkUsages []*ChunkWrittenIntervalList
|
|
||||||
ChunkSize int64
|
|
||||||
sync.Mutex
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = io.WriterAt(&ChunkedFileWriter{})
|
|
||||||
|
|
||||||
func NewChunkedFileWriter(dir string, chunkSize int64) *ChunkedFileWriter {
|
|
||||||
return &ChunkedFileWriter{
|
|
||||||
dir: dir,
|
|
||||||
file: nil,
|
|
||||||
logicToActualChunkIndex: make(map[LogicChunkIndex]ActualChunkIndex),
|
|
||||||
ChunkSize: chunkSize,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cw *ChunkedFileWriter) WriteAt(p []byte, off int64) (n int, err error) {
|
|
||||||
cw.Lock()
|
|
||||||
defer cw.Unlock()
|
|
||||||
|
|
||||||
if cw.file == nil {
|
|
||||||
cw.file, err = os.CreateTemp(cw.dir, "")
|
|
||||||
if err != nil {
|
|
||||||
glog.Errorf("create temp file: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
actualOffset, chunkUsage := cw.toActualWriteOffset(off)
|
|
||||||
n, err = cw.file.WriteAt(p, actualOffset)
|
|
||||||
if err == nil {
|
|
||||||
startOffset := off % cw.ChunkSize
|
|
||||||
chunkUsage.MarkWritten(startOffset, startOffset+int64(n))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cw *ChunkedFileWriter) ReadDataAt(p []byte, off int64) (maxStop int64) {
|
|
||||||
cw.Lock()
|
|
||||||
defer cw.Unlock()
|
|
||||||
|
|
||||||
if cw.file == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
logicChunkIndex := off / cw.ChunkSize
|
|
||||||
actualChunkIndex, chunkUsage := cw.toActualReadOffset(off)
|
|
||||||
if chunkUsage != nil {
|
|
||||||
for t := chunkUsage.head.next; t != chunkUsage.tail; t = t.next {
|
|
||||||
logicStart := max(off, logicChunkIndex*cw.ChunkSize+t.StartOffset)
|
|
||||||
logicStop := min(off+int64(len(p)), logicChunkIndex*cw.ChunkSize+t.stopOffset)
|
|
||||||
if logicStart < logicStop {
|
|
||||||
actualStart := logicStart - logicChunkIndex*cw.ChunkSize + int64(actualChunkIndex)*cw.ChunkSize
|
|
||||||
_, err := cw.file.ReadAt(p[logicStart-off:logicStop-off], actualStart)
|
|
||||||
if err != nil {
|
|
||||||
glog.Errorf("reading temp file: %v", err)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
maxStop = max(maxStop, logicStop)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cw *ChunkedFileWriter) toActualWriteOffset(logicOffset int64) (actualOffset int64, chunkUsage *ChunkWrittenIntervalList) {
|
|
||||||
logicChunkIndex := LogicChunkIndex(logicOffset / cw.ChunkSize)
|
|
||||||
offsetRemainder := logicOffset % cw.ChunkSize
|
|
||||||
existingActualChunkIndex, found := cw.logicToActualChunkIndex[logicChunkIndex]
|
|
||||||
if found {
|
|
||||||
return int64(existingActualChunkIndex)*cw.ChunkSize + offsetRemainder, cw.chunkUsages[existingActualChunkIndex]
|
|
||||||
}
|
|
||||||
cw.logicToActualChunkIndex[logicChunkIndex] = ActualChunkIndex(len(cw.chunkUsages))
|
|
||||||
chunkUsage = newChunkWrittenIntervalList()
|
|
||||||
cw.chunkUsages = append(cw.chunkUsages, chunkUsage)
|
|
||||||
return int64(len(cw.chunkUsages)-1)*cw.ChunkSize + offsetRemainder, chunkUsage
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cw *ChunkedFileWriter) toActualReadOffset(logicOffset int64) (actualChunkIndex ActualChunkIndex, chunkUsage *ChunkWrittenIntervalList) {
|
|
||||||
logicChunkIndex := LogicChunkIndex(logicOffset / cw.ChunkSize)
|
|
||||||
existingActualChunkIndex, found := cw.logicToActualChunkIndex[logicChunkIndex]
|
|
||||||
if found {
|
|
||||||
return existingActualChunkIndex, cw.chunkUsages[existingActualChunkIndex]
|
|
||||||
}
|
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cw *ChunkedFileWriter) ProcessEachInterval(process func(file *os.File, logicChunkIndex LogicChunkIndex, interval *ChunkWrittenInterval)) {
|
|
||||||
for logicChunkIndex, actualChunkIndex := range cw.logicToActualChunkIndex {
|
|
||||||
chunkUsage := cw.chunkUsages[actualChunkIndex]
|
|
||||||
for t := chunkUsage.head.next; t != chunkUsage.tail; t = t.next {
|
|
||||||
process(cw.file, logicChunkIndex, t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset releases used resources
|
|
||||||
func (cw *ChunkedFileWriter) Reset() {
|
|
||||||
if cw.file != nil {
|
|
||||||
cw.file.Close()
|
|
||||||
os.Remove(cw.file.Name())
|
|
||||||
cw.file = nil
|
|
||||||
}
|
|
||||||
cw.logicToActualChunkIndex = make(map[LogicChunkIndex]ActualChunkIndex)
|
|
||||||
cw.chunkUsages = cw.chunkUsages[:0]
|
|
||||||
}
|
|
||||||
|
|
||||||
type FileIntervalReader struct {
|
|
||||||
f *os.File
|
|
||||||
startOffset int64
|
|
||||||
stopOffset int64
|
|
||||||
position int64
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = io.Reader(&FileIntervalReader{})
|
|
||||||
|
|
||||||
func NewFileIntervalReader(cw *ChunkedFileWriter, logicChunkIndex LogicChunkIndex, interval *ChunkWrittenInterval) *FileIntervalReader {
|
|
||||||
actualChunkIndex, found := cw.logicToActualChunkIndex[logicChunkIndex]
|
|
||||||
if !found {
|
|
||||||
// this should never happen
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &FileIntervalReader{
|
|
||||||
f: cw.file,
|
|
||||||
startOffset: int64(actualChunkIndex)*cw.ChunkSize + interval.StartOffset,
|
|
||||||
stopOffset: int64(actualChunkIndex)*cw.ChunkSize + interval.stopOffset,
|
|
||||||
position: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fr *FileIntervalReader) Read(p []byte) (n int, err error) {
|
|
||||||
readSize := minInt(len(p), int(fr.stopOffset-fr.startOffset-fr.position))
|
|
||||||
n, err = fr.f.ReadAt(p[:readSize], fr.startOffset+fr.position)
|
|
||||||
if err == nil || err == io.EOF {
|
|
||||||
fr.position += int64(n)
|
|
||||||
if fr.stopOffset-fr.startOffset-fr.position == 0 {
|
|
||||||
// return a tiny bit faster
|
|
||||||
err = io.EOF
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
package page_writer
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestChunkedFileWriter_toActualOffset(t *testing.T) {
|
|
||||||
cw := NewChunkedFileWriter("", 16)
|
|
||||||
|
|
||||||
writeToFile(cw, 50, 60)
|
|
||||||
writeToFile(cw, 60, 64)
|
|
||||||
|
|
||||||
writeToFile(cw, 32, 40)
|
|
||||||
writeToFile(cw, 42, 48)
|
|
||||||
|
|
||||||
writeToFile(cw, 48, 50)
|
|
||||||
|
|
||||||
assert.Equal(t, 1, cw.chunkUsages[0].size(), "fully covered")
|
|
||||||
assert.Equal(t, 2, cw.chunkUsages[1].size(), "2 intervals")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeToFile(cw *ChunkedFileWriter, startOffset int64, stopOffset int64) {
|
|
||||||
|
|
||||||
_, chunkUsage := cw.toActualWriteOffset(startOffset)
|
|
||||||
|
|
||||||
// skip doing actual writing
|
|
||||||
|
|
||||||
innerOffset := startOffset % cw.ChunkSize
|
|
||||||
chunkUsage.MarkWritten(innerOffset, innerOffset+stopOffset-startOffset)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteChunkedFile(t *testing.T) {
|
|
||||||
x := NewChunkedFileWriter(os.TempDir(), 20)
|
|
||||||
defer x.Reset()
|
|
||||||
y := NewChunkedFileWriter(os.TempDir(), 12)
|
|
||||||
defer y.Reset()
|
|
||||||
|
|
||||||
batchSize := 4
|
|
||||||
buf := make([]byte, batchSize)
|
|
||||||
for i := 0; i < 256; i++ {
|
|
||||||
for x := 0; x < batchSize; x++ {
|
|
||||||
buf[x] = byte(i)
|
|
||||||
}
|
|
||||||
x.WriteAt(buf, int64(i*batchSize))
|
|
||||||
y.WriteAt(buf, int64((255-i)*batchSize))
|
|
||||||
}
|
|
||||||
|
|
||||||
a := make([]byte, 1)
|
|
||||||
b := make([]byte, 1)
|
|
||||||
for i := 0; i < 256*batchSize; i++ {
|
|
||||||
x.ReadDataAt(a, int64(i))
|
|
||||||
y.ReadDataAt(b, int64(256*batchSize-1-i))
|
|
||||||
assert.Equal(t, a[0], b[0], "same read")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package page_writer
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
type SaveToStorageFunc func(reader io.Reader, offset int64, size int64, cleanupFn func())
|
|
||||||
|
|
||||||
type MemChunk struct {
|
|
||||||
buf []byte
|
|
||||||
usage *ChunkWrittenIntervalList
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SaveToStorageFunc func(reader io.Reader, offset int64, size int64, cleanupFn func())
|
||||||
|
|
||||||
|
type PageChunk interface {
|
||||||
|
FreeResource()
|
||||||
|
WriteDataAt(src []byte, offset int64) (n int)
|
||||||
|
ReadDataAt(p []byte, off int64) (maxStop int64)
|
||||||
|
IsComplete() bool
|
||||||
|
WrittenSize() int64
|
||||||
|
SaveContent(saveFn SaveToStorageFunc)
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util/mem"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ = PageChunk(&MemChunk{})
|
||||||
|
)
|
||||||
|
|
||||||
|
type MemChunk struct {
|
||||||
|
buf []byte
|
||||||
|
usage *ChunkWrittenIntervalList
|
||||||
|
chunkSize int64
|
||||||
|
logicChunkIndex LogicChunkIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMemChunk(logicChunkIndex LogicChunkIndex, chunkSize int64) *MemChunk {
|
||||||
|
return &MemChunk{
|
||||||
|
logicChunkIndex: logicChunkIndex,
|
||||||
|
chunkSize: chunkSize,
|
||||||
|
buf: mem.Allocate(int(chunkSize)),
|
||||||
|
usage: newChunkWrittenIntervalList(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) FreeResource() {
|
||||||
|
mem.Free(mc.buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) WriteDataAt(src []byte, offset int64) (n int) {
|
||||||
|
innerOffset := offset % mc.chunkSize
|
||||||
|
n = copy(mc.buf[innerOffset:], src)
|
||||||
|
mc.usage.MarkWritten(innerOffset, innerOffset+int64(n))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) ReadDataAt(p []byte, off int64) (maxStop int64) {
|
||||||
|
memChunkBaseOffset := int64(mc.logicChunkIndex) * mc.chunkSize
|
||||||
|
for t := mc.usage.head.next; t != mc.usage.tail; t = t.next {
|
||||||
|
logicStart := max(off, int64(mc.logicChunkIndex)*mc.chunkSize+t.StartOffset)
|
||||||
|
logicStop := min(off+int64(len(p)), memChunkBaseOffset+t.stopOffset)
|
||||||
|
if logicStart < logicStop {
|
||||||
|
copy(p[logicStart-off:logicStop-off], mc.buf[logicStart-memChunkBaseOffset:logicStop-memChunkBaseOffset])
|
||||||
|
maxStop = max(maxStop, logicStop)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) IsComplete() bool {
|
||||||
|
return mc.usage.IsComplete(mc.chunkSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) WrittenSize() int64 {
|
||||||
|
return mc.usage.WrittenSize()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) SaveContent(saveFn SaveToStorageFunc) {
|
||||||
|
if saveFn == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for t := mc.usage.head.next; t != mc.usage.tail; t = t.next {
|
||||||
|
reader := util.NewBytesReader(mc.buf[t.StartOffset:t.stopOffset])
|
||||||
|
saveFn(reader, int64(mc.logicChunkIndex)*mc.chunkSize+t.StartOffset, t.Size(), func() {
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util/mem"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ = PageChunk(&SwapFileChunk{})
|
||||||
|
)
|
||||||
|
|
||||||
|
type ActualChunkIndex int
|
||||||
|
|
||||||
|
type SwapFile struct {
|
||||||
|
dir string
|
||||||
|
file *os.File
|
||||||
|
logicToActualChunkIndex map[LogicChunkIndex]ActualChunkIndex
|
||||||
|
chunkSize int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type SwapFileChunk struct {
|
||||||
|
swapfile *SwapFile
|
||||||
|
usage *ChunkWrittenIntervalList
|
||||||
|
logicChunkIndex LogicChunkIndex
|
||||||
|
actualChunkIndex ActualChunkIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSwapFile(dir string, chunkSize int64) *SwapFile {
|
||||||
|
return &SwapFile{
|
||||||
|
dir: dir,
|
||||||
|
file: nil,
|
||||||
|
logicToActualChunkIndex: make(map[LogicChunkIndex]ActualChunkIndex),
|
||||||
|
chunkSize: chunkSize,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (sf *SwapFile) FreeResource() {
|
||||||
|
if sf.file != nil {
|
||||||
|
sf.file.Close()
|
||||||
|
os.Remove(sf.file.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sf *SwapFile) NewTempFileChunk(logicChunkIndex LogicChunkIndex) (tc *SwapFileChunk) {
|
||||||
|
if sf.file == nil {
|
||||||
|
var err error
|
||||||
|
sf.file, err = os.CreateTemp(sf.dir, "")
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("create swap file: %v", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
actualChunkIndex, found := sf.logicToActualChunkIndex[logicChunkIndex]
|
||||||
|
if !found {
|
||||||
|
actualChunkIndex = ActualChunkIndex(len(sf.logicToActualChunkIndex))
|
||||||
|
sf.logicToActualChunkIndex[logicChunkIndex] = actualChunkIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
return &SwapFileChunk{
|
||||||
|
swapfile: sf,
|
||||||
|
usage: newChunkWrittenIntervalList(),
|
||||||
|
logicChunkIndex: logicChunkIndex,
|
||||||
|
actualChunkIndex: actualChunkIndex,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) FreeResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) WriteDataAt(src []byte, offset int64) (n int) {
|
||||||
|
innerOffset := offset % sc.swapfile.chunkSize
|
||||||
|
var err error
|
||||||
|
n, err = sc.swapfile.file.WriteAt(src, int64(sc.actualChunkIndex)*sc.swapfile.chunkSize+innerOffset)
|
||||||
|
if err == nil {
|
||||||
|
sc.usage.MarkWritten(innerOffset, innerOffset+int64(n))
|
||||||
|
} else {
|
||||||
|
glog.Errorf("failed to write swap file %s: %v", sc.swapfile.file.Name(), err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) ReadDataAt(p []byte, off int64) (maxStop int64) {
|
||||||
|
chunkStartOffset := int64(sc.logicChunkIndex) * sc.swapfile.chunkSize
|
||||||
|
for t := sc.usage.head.next; t != sc.usage.tail; t = t.next {
|
||||||
|
logicStart := max(off, chunkStartOffset+t.StartOffset)
|
||||||
|
logicStop := min(off+int64(len(p)), chunkStartOffset+t.stopOffset)
|
||||||
|
if logicStart < logicStop {
|
||||||
|
actualStart := logicStart - chunkStartOffset + int64(sc.actualChunkIndex)*sc.swapfile.chunkSize
|
||||||
|
if _, err := sc.swapfile.file.ReadAt(p[logicStart-off:logicStop-off], actualStart); err != nil {
|
||||||
|
glog.Errorf("failed to reading swap file %s: %v", sc.swapfile.file.Name(), err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
maxStop = max(maxStop, logicStop)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) IsComplete() bool {
|
||||||
|
return sc.usage.IsComplete(sc.swapfile.chunkSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) WrittenSize() int64 {
|
||||||
|
return sc.usage.WrittenSize()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) SaveContent(saveFn SaveToStorageFunc) {
|
||||||
|
if saveFn == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for t := sc.usage.head.next; t != sc.usage.tail; t = t.next {
|
||||||
|
data := mem.Allocate(int(t.Size()))
|
||||||
|
sc.swapfile.file.ReadAt(data, t.StartOffset+int64(sc.actualChunkIndex)*sc.swapfile.chunkSize)
|
||||||
|
reader := util.NewBytesReader(data)
|
||||||
|
saveFn(reader, int64(sc.logicChunkIndex)*sc.swapfile.chunkSize+t.StartOffset, t.Size(), func() {
|
||||||
|
})
|
||||||
|
mem.Free(data)
|
||||||
|
}
|
||||||
|
sc.usage = newChunkWrittenIntervalList()
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util/mem"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@@ -15,20 +14,21 @@ type LogicChunkIndex int
|
|||||||
type UploadPipeline struct {
|
type UploadPipeline struct {
|
||||||
filepath util.FullPath
|
filepath util.FullPath
|
||||||
ChunkSize int64
|
ChunkSize int64
|
||||||
writers *util.LimitedConcurrentExecutor
|
writableChunks map[LogicChunkIndex]PageChunk
|
||||||
writableChunks map[LogicChunkIndex]*MemChunk
|
|
||||||
writableChunksLock sync.Mutex
|
writableChunksLock sync.Mutex
|
||||||
sealedChunks map[LogicChunkIndex]*SealedChunk
|
sealedChunks map[LogicChunkIndex]*SealedChunk
|
||||||
sealedChunksLock sync.Mutex
|
sealedChunksLock sync.Mutex
|
||||||
activeWriterCond *sync.Cond
|
uploaders *util.LimitedConcurrentExecutor
|
||||||
activeWriterCount int32
|
uploaderCount int32
|
||||||
|
uploaderCountCond *sync.Cond
|
||||||
|
saveToStorageFn SaveToStorageFunc
|
||||||
activeReadChunks map[LogicChunkIndex]int
|
activeReadChunks map[LogicChunkIndex]int
|
||||||
activeReadChunksLock sync.Mutex
|
activeReadChunksLock sync.Mutex
|
||||||
saveToStorageFn SaveToStorageFunc
|
bufferChunkLimit int
|
||||||
}
|
}
|
||||||
|
|
||||||
type SealedChunk struct {
|
type SealedChunk struct {
|
||||||
chunk *MemChunk
|
chunk PageChunk
|
||||||
referenceCounter int // track uploading or reading processes
|
referenceCounter int // track uploading or reading processes
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,221 +36,147 @@ func (sc *SealedChunk) FreeReference(messageOnFree string) {
|
|||||||
sc.referenceCounter--
|
sc.referenceCounter--
|
||||||
if sc.referenceCounter == 0 {
|
if sc.referenceCounter == 0 {
|
||||||
glog.V(4).Infof("Free sealed chunk: %s", messageOnFree)
|
glog.V(4).Infof("Free sealed chunk: %s", messageOnFree)
|
||||||
mem.Free(sc.chunk.buf)
|
sc.chunk.FreeResource()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUploadPipeline(filepath util.FullPath, writers *util.LimitedConcurrentExecutor, chunkSize int64, saveToStorageFn SaveToStorageFunc) *UploadPipeline {
|
func NewUploadPipeline(writers *util.LimitedConcurrentExecutor, chunkSize int64, saveToStorageFn SaveToStorageFunc, bufferChunkLimit int) *UploadPipeline {
|
||||||
return &UploadPipeline{
|
return &UploadPipeline{
|
||||||
ChunkSize: chunkSize,
|
ChunkSize: chunkSize,
|
||||||
writableChunks: make(map[LogicChunkIndex]*MemChunk),
|
writableChunks: make(map[LogicChunkIndex]PageChunk),
|
||||||
sealedChunks: make(map[LogicChunkIndex]*SealedChunk),
|
sealedChunks: make(map[LogicChunkIndex]*SealedChunk),
|
||||||
writers: writers,
|
uploaders: writers,
|
||||||
activeWriterCond: sync.NewCond(&sync.Mutex{}),
|
uploaderCountCond: sync.NewCond(&sync.Mutex{}),
|
||||||
saveToStorageFn: saveToStorageFn,
|
saveToStorageFn: saveToStorageFn,
|
||||||
filepath: filepath,
|
activeReadChunks: make(map[LogicChunkIndex]int),
|
||||||
activeReadChunks: make(map[LogicChunkIndex]int),
|
bufferChunkLimit: bufferChunkLimit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cw *UploadPipeline) SaveDataAt(p []byte, off int64) (n int) {
|
func (up *UploadPipeline) SaveDataAt(p []byte, off int64) (n int) {
|
||||||
cw.writableChunksLock.Lock()
|
up.writableChunksLock.Lock()
|
||||||
defer cw.writableChunksLock.Unlock()
|
defer up.writableChunksLock.Unlock()
|
||||||
|
|
||||||
logicChunkIndex := LogicChunkIndex(off / cw.ChunkSize)
|
logicChunkIndex := LogicChunkIndex(off / up.ChunkSize)
|
||||||
offsetRemainder := off % cw.ChunkSize
|
|
||||||
|
|
||||||
memChunk, found := cw.writableChunks[logicChunkIndex]
|
memChunk, found := up.writableChunks[logicChunkIndex]
|
||||||
if !found {
|
if !found {
|
||||||
memChunk = &MemChunk{
|
if len(up.writableChunks) < up.bufferChunkLimit {
|
||||||
buf: mem.Allocate(int(cw.ChunkSize)),
|
memChunk = NewMemChunk(logicChunkIndex, up.ChunkSize)
|
||||||
usage: newChunkWrittenIntervalList(),
|
} else {
|
||||||
|
fullestChunkIndex, fullness := LogicChunkIndex(-1), int64(0)
|
||||||
|
for lci, mc := range up.writableChunks {
|
||||||
|
chunkFullness := mc.WrittenSize()
|
||||||
|
if fullness < chunkFullness {
|
||||||
|
fullestChunkIndex = lci
|
||||||
|
fullness = chunkFullness
|
||||||
|
}
|
||||||
|
}
|
||||||
|
up.moveToSealed(up.writableChunks[fullestChunkIndex], fullestChunkIndex)
|
||||||
|
delete(up.writableChunks, fullestChunkIndex)
|
||||||
|
fmt.Printf("flush chunk %d with %d bytes written", logicChunkIndex, fullness)
|
||||||
|
memChunk = NewMemChunk(logicChunkIndex, up.ChunkSize)
|
||||||
}
|
}
|
||||||
cw.writableChunks[logicChunkIndex] = memChunk
|
up.writableChunks[logicChunkIndex] = memChunk
|
||||||
}
|
}
|
||||||
n = copy(memChunk.buf[offsetRemainder:], p)
|
n = memChunk.WriteDataAt(p, off)
|
||||||
memChunk.usage.MarkWritten(offsetRemainder, offsetRemainder+int64(n))
|
up.maybeMoveToSealed(memChunk, logicChunkIndex)
|
||||||
cw.maybeMoveToSealed(memChunk, logicChunkIndex)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cw *UploadPipeline) MaybeReadDataAt(p []byte, off int64) (maxStop int64) {
|
func (up *UploadPipeline) MaybeReadDataAt(p []byte, off int64) (maxStop int64) {
|
||||||
logicChunkIndex := LogicChunkIndex(off / cw.ChunkSize)
|
logicChunkIndex := LogicChunkIndex(off / up.ChunkSize)
|
||||||
|
|
||||||
// read from sealed chunks first
|
// read from sealed chunks first
|
||||||
cw.sealedChunksLock.Lock()
|
up.sealedChunksLock.Lock()
|
||||||
sealedChunk, found := cw.sealedChunks[logicChunkIndex]
|
sealedChunk, found := up.sealedChunks[logicChunkIndex]
|
||||||
if found {
|
if found {
|
||||||
sealedChunk.referenceCounter++
|
sealedChunk.referenceCounter++
|
||||||
}
|
}
|
||||||
cw.sealedChunksLock.Unlock()
|
up.sealedChunksLock.Unlock()
|
||||||
if found {
|
if found {
|
||||||
maxStop = readMemChunk(sealedChunk.chunk, p, off, logicChunkIndex, cw.ChunkSize)
|
maxStop = sealedChunk.chunk.ReadDataAt(p, off)
|
||||||
glog.V(4).Infof("%s read sealed memchunk [%d,%d)", cw.filepath, off, maxStop)
|
glog.V(4).Infof("%s read sealed memchunk [%d,%d)", up.filepath, off, maxStop)
|
||||||
sealedChunk.FreeReference(fmt.Sprintf("%s finish reading chunk %d", cw.filepath, logicChunkIndex))
|
sealedChunk.FreeReference(fmt.Sprintf("%s finish reading chunk %d", up.filepath, logicChunkIndex))
|
||||||
}
|
}
|
||||||
|
|
||||||
// read from writable chunks last
|
// read from writable chunks last
|
||||||
cw.writableChunksLock.Lock()
|
up.writableChunksLock.Lock()
|
||||||
defer cw.writableChunksLock.Unlock()
|
defer up.writableChunksLock.Unlock()
|
||||||
writableChunk, found := cw.writableChunks[logicChunkIndex]
|
writableChunk, found := up.writableChunks[logicChunkIndex]
|
||||||
if !found {
|
if !found {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
writableMaxStop := readMemChunk(writableChunk, p, off, logicChunkIndex, cw.ChunkSize)
|
writableMaxStop := writableChunk.ReadDataAt(p, off)
|
||||||
glog.V(4).Infof("%s read writable memchunk [%d,%d)", cw.filepath, off, writableMaxStop)
|
glog.V(4).Infof("%s read writable memchunk [%d,%d)", up.filepath, off, writableMaxStop)
|
||||||
maxStop = max(maxStop, writableMaxStop)
|
maxStop = max(maxStop, writableMaxStop)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cw *UploadPipeline) FlushAll() {
|
func (up *UploadPipeline) FlushAll() {
|
||||||
cw.writableChunksLock.Lock()
|
up.writableChunksLock.Lock()
|
||||||
defer cw.writableChunksLock.Unlock()
|
defer up.writableChunksLock.Unlock()
|
||||||
|
|
||||||
for logicChunkIndex, memChunk := range cw.writableChunks {
|
for logicChunkIndex, memChunk := range up.writableChunks {
|
||||||
cw.moveToSealed(memChunk, logicChunkIndex)
|
up.moveToSealed(memChunk, logicChunkIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
cw.waitForCurrentWritersToComplete()
|
up.waitForCurrentWritersToComplete()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cw *UploadPipeline) LockForRead(startOffset, stopOffset int64) {
|
func (up *UploadPipeline) maybeMoveToSealed(memChunk PageChunk, logicChunkIndex LogicChunkIndex) {
|
||||||
startLogicChunkIndex := LogicChunkIndex(startOffset / cw.ChunkSize)
|
if memChunk.IsComplete() {
|
||||||
stopLogicChunkIndex := LogicChunkIndex(stopOffset / cw.ChunkSize)
|
up.moveToSealed(memChunk, logicChunkIndex)
|
||||||
if stopOffset%cw.ChunkSize > 0 {
|
|
||||||
stopLogicChunkIndex += 1
|
|
||||||
}
|
|
||||||
cw.activeReadChunksLock.Lock()
|
|
||||||
defer cw.activeReadChunksLock.Unlock()
|
|
||||||
for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ {
|
|
||||||
if count, found := cw.activeReadChunks[i]; found {
|
|
||||||
cw.activeReadChunks[i] = count + 1
|
|
||||||
} else {
|
|
||||||
cw.activeReadChunks[i] = 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cw *UploadPipeline) UnlockForRead(startOffset, stopOffset int64) {
|
func (up *UploadPipeline) moveToSealed(memChunk PageChunk, logicChunkIndex LogicChunkIndex) {
|
||||||
startLogicChunkIndex := LogicChunkIndex(startOffset / cw.ChunkSize)
|
atomic.AddInt32(&up.uploaderCount, 1)
|
||||||
stopLogicChunkIndex := LogicChunkIndex(stopOffset / cw.ChunkSize)
|
glog.V(4).Infof("%s uploaderCount %d ++> %d", up.filepath, up.uploaderCount-1, up.uploaderCount)
|
||||||
if stopOffset%cw.ChunkSize > 0 {
|
|
||||||
stopLogicChunkIndex += 1
|
|
||||||
}
|
|
||||||
cw.activeReadChunksLock.Lock()
|
|
||||||
defer cw.activeReadChunksLock.Unlock()
|
|
||||||
for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ {
|
|
||||||
if count, found := cw.activeReadChunks[i]; found {
|
|
||||||
if count == 1 {
|
|
||||||
delete(cw.activeReadChunks, i)
|
|
||||||
} else {
|
|
||||||
cw.activeReadChunks[i] = count - 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cw *UploadPipeline) IsLocked(logicChunkIndex LogicChunkIndex) bool {
|
up.sealedChunksLock.Lock()
|
||||||
cw.activeReadChunksLock.Lock()
|
|
||||||
defer cw.activeReadChunksLock.Unlock()
|
|
||||||
if count, found := cw.activeReadChunks[logicChunkIndex]; found {
|
|
||||||
return count > 0
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cw *UploadPipeline) waitForCurrentWritersToComplete() {
|
if oldMemChunk, found := up.sealedChunks[logicChunkIndex]; found {
|
||||||
cw.activeWriterCond.L.Lock()
|
oldMemChunk.FreeReference(fmt.Sprintf("%s replace chunk %d", up.filepath, logicChunkIndex))
|
||||||
t := int32(100)
|
|
||||||
for {
|
|
||||||
t = atomic.LoadInt32(&cw.activeWriterCount)
|
|
||||||
if t <= 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
glog.V(4).Infof("activeWriterCond is %d", t)
|
|
||||||
cw.activeWriterCond.Wait()
|
|
||||||
}
|
|
||||||
cw.activeWriterCond.L.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cw *UploadPipeline) maybeMoveToSealed(memChunk *MemChunk, logicChunkIndex LogicChunkIndex) {
|
|
||||||
if memChunk.usage.IsComplete(cw.ChunkSize) {
|
|
||||||
cw.moveToSealed(memChunk, logicChunkIndex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cw *UploadPipeline) moveToSealed(memChunk *MemChunk, logicChunkIndex LogicChunkIndex) {
|
|
||||||
atomic.AddInt32(&cw.activeWriterCount, 1)
|
|
||||||
glog.V(4).Infof("%s activeWriterCount %d ++> %d", cw.filepath, cw.activeWriterCount-1, cw.activeWriterCount)
|
|
||||||
|
|
||||||
cw.sealedChunksLock.Lock()
|
|
||||||
|
|
||||||
if oldMemChunk, found := cw.sealedChunks[logicChunkIndex]; found {
|
|
||||||
oldMemChunk.FreeReference(fmt.Sprintf("%s replace chunk %d", cw.filepath, logicChunkIndex))
|
|
||||||
}
|
}
|
||||||
sealedChunk := &SealedChunk{
|
sealedChunk := &SealedChunk{
|
||||||
chunk: memChunk,
|
chunk: memChunk,
|
||||||
referenceCounter: 1, // default 1 is for uploading process
|
referenceCounter: 1, // default 1 is for uploading process
|
||||||
}
|
}
|
||||||
cw.sealedChunks[logicChunkIndex] = sealedChunk
|
up.sealedChunks[logicChunkIndex] = sealedChunk
|
||||||
delete(cw.writableChunks, logicChunkIndex)
|
delete(up.writableChunks, logicChunkIndex)
|
||||||
|
|
||||||
cw.sealedChunksLock.Unlock()
|
up.sealedChunksLock.Unlock()
|
||||||
|
|
||||||
cw.writers.Execute(func() {
|
up.uploaders.Execute(func() {
|
||||||
// first add to the file chunks
|
// first add to the file chunks
|
||||||
cw.saveOneChunk(sealedChunk.chunk, logicChunkIndex)
|
sealedChunk.chunk.SaveContent(up.saveToStorageFn)
|
||||||
|
|
||||||
// notify waiting process
|
// notify waiting process
|
||||||
atomic.AddInt32(&cw.activeWriterCount, -1)
|
atomic.AddInt32(&up.uploaderCount, -1)
|
||||||
glog.V(4).Infof("%s activeWriterCount %d --> %d", cw.filepath, cw.activeWriterCount+1, cw.activeWriterCount)
|
glog.V(4).Infof("%s uploaderCount %d --> %d", up.filepath, up.uploaderCount+1, up.uploaderCount)
|
||||||
// Lock and Unlock are not required,
|
// Lock and Unlock are not required,
|
||||||
// but it may signal multiple times during one wakeup,
|
// but it may signal multiple times during one wakeup,
|
||||||
// and the waiting goroutine may miss some of them!
|
// and the waiting goroutine may miss some of them!
|
||||||
cw.activeWriterCond.L.Lock()
|
up.uploaderCountCond.L.Lock()
|
||||||
cw.activeWriterCond.Broadcast()
|
up.uploaderCountCond.Broadcast()
|
||||||
cw.activeWriterCond.L.Unlock()
|
up.uploaderCountCond.L.Unlock()
|
||||||
|
|
||||||
// wait for readers
|
// wait for readers
|
||||||
for cw.IsLocked(logicChunkIndex) {
|
for up.IsLocked(logicChunkIndex) {
|
||||||
time.Sleep(59 * time.Millisecond)
|
time.Sleep(59 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
// then remove from sealed chunks
|
// then remove from sealed chunks
|
||||||
cw.sealedChunksLock.Lock()
|
up.sealedChunksLock.Lock()
|
||||||
defer cw.sealedChunksLock.Unlock()
|
defer up.sealedChunksLock.Unlock()
|
||||||
delete(cw.sealedChunks, logicChunkIndex)
|
delete(up.sealedChunks, logicChunkIndex)
|
||||||
sealedChunk.FreeReference(fmt.Sprintf("%s finished uploading chunk %d", cw.filepath, logicChunkIndex))
|
sealedChunk.FreeReference(fmt.Sprintf("%s finished uploading chunk %d", up.filepath, logicChunkIndex))
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cw *UploadPipeline) saveOneChunk(memChunk *MemChunk, logicChunkIndex LogicChunkIndex) {
|
func (up *UploadPipeline) Shutdown() {
|
||||||
if cw.saveToStorageFn == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for t := memChunk.usage.head.next; t != memChunk.usage.tail; t = t.next {
|
|
||||||
reader := util.NewBytesReader(memChunk.buf[t.StartOffset:t.stopOffset])
|
|
||||||
cw.saveToStorageFn(reader, int64(logicChunkIndex)*cw.ChunkSize+t.StartOffset, t.Size(), func() {
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func readMemChunk(memChunk *MemChunk, p []byte, off int64, logicChunkIndex LogicChunkIndex, chunkSize int64) (maxStop int64) {
|
|
||||||
memChunkBaseOffset := int64(logicChunkIndex) * chunkSize
|
|
||||||
for t := memChunk.usage.head.next; t != memChunk.usage.tail; t = t.next {
|
|
||||||
logicStart := max(off, int64(logicChunkIndex)*chunkSize+t.StartOffset)
|
|
||||||
logicStop := min(off+int64(len(p)), memChunkBaseOffset+t.stopOffset)
|
|
||||||
if logicStart < logicStop {
|
|
||||||
copy(p[logicStart-off:logicStop-off], memChunk.buf[logicStart-memChunkBaseOffset:logicStop-memChunkBaseOffset])
|
|
||||||
maxStop = max(maxStop, logicStop)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p2 *UploadPipeline) Shutdown() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync/atomic"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (up *UploadPipeline) LockForRead(startOffset, stopOffset int64) {
|
||||||
|
startLogicChunkIndex := LogicChunkIndex(startOffset / up.ChunkSize)
|
||||||
|
stopLogicChunkIndex := LogicChunkIndex(stopOffset / up.ChunkSize)
|
||||||
|
if stopOffset%up.ChunkSize > 0 {
|
||||||
|
stopLogicChunkIndex += 1
|
||||||
|
}
|
||||||
|
up.activeReadChunksLock.Lock()
|
||||||
|
defer up.activeReadChunksLock.Unlock()
|
||||||
|
for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ {
|
||||||
|
if count, found := up.activeReadChunks[i]; found {
|
||||||
|
up.activeReadChunks[i] = count + 1
|
||||||
|
} else {
|
||||||
|
up.activeReadChunks[i] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) UnlockForRead(startOffset, stopOffset int64) {
|
||||||
|
startLogicChunkIndex := LogicChunkIndex(startOffset / up.ChunkSize)
|
||||||
|
stopLogicChunkIndex := LogicChunkIndex(stopOffset / up.ChunkSize)
|
||||||
|
if stopOffset%up.ChunkSize > 0 {
|
||||||
|
stopLogicChunkIndex += 1
|
||||||
|
}
|
||||||
|
up.activeReadChunksLock.Lock()
|
||||||
|
defer up.activeReadChunksLock.Unlock()
|
||||||
|
for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ {
|
||||||
|
if count, found := up.activeReadChunks[i]; found {
|
||||||
|
if count == 1 {
|
||||||
|
delete(up.activeReadChunks, i)
|
||||||
|
} else {
|
||||||
|
up.activeReadChunks[i] = count - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) IsLocked(logicChunkIndex LogicChunkIndex) bool {
|
||||||
|
up.activeReadChunksLock.Lock()
|
||||||
|
defer up.activeReadChunksLock.Unlock()
|
||||||
|
if count, found := up.activeReadChunks[logicChunkIndex]; found {
|
||||||
|
return count > 0
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) waitForCurrentWritersToComplete() {
|
||||||
|
up.uploaderCountCond.L.Lock()
|
||||||
|
t := int32(100)
|
||||||
|
for {
|
||||||
|
t = atomic.LoadInt32(&up.uploaderCount)
|
||||||
|
if t <= 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
up.uploaderCountCond.Wait()
|
||||||
|
}
|
||||||
|
up.uploaderCountCond.L.Unlock()
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
func TestUploadPipeline(t *testing.T) {
|
func TestUploadPipeline(t *testing.T) {
|
||||||
|
|
||||||
uploadPipeline := NewUploadPipeline("", nil, 2*1024*1024, nil)
|
uploadPipeline := NewUploadPipeline(nil, 2*1024*1024, nil, 16)
|
||||||
|
|
||||||
writeRange(uploadPipeline, 0, 131072)
|
writeRange(uploadPipeline, 0, 131072)
|
||||||
writeRange(uploadPipeline, 131072, 262144)
|
writeRange(uploadPipeline, 131072, 262144)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package images
|
package images
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -12,7 +13,7 @@ func TestXYZ(t *testing.T) {
|
|||||||
|
|
||||||
fixed_data := FixJpgOrientation(dat)
|
fixed_data := FixJpgOrientation(dat)
|
||||||
|
|
||||||
os.WriteFile("fixed1.jpg", fixed_data, 0644)
|
util.WriteFile("fixed1.jpg", fixed_data, 0644)
|
||||||
|
|
||||||
os.Remove("fixed1.jpg")
|
os.Remove("fixed1.jpg")
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package images
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -15,7 +16,7 @@ func TestResizing(t *testing.T) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
buf.ReadFrom(resized)
|
buf.ReadFrom(resized)
|
||||||
|
|
||||||
os.WriteFile("resized1.png", buf.Bytes(), 0644)
|
util.WriteFile("resized1.png", buf.Bytes(), 0644)
|
||||||
|
|
||||||
os.Remove("resized1.png")
|
os.Remove("resized1.png")
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fs"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Directory struct {
|
||||||
|
fs.Inode
|
||||||
|
|
||||||
|
name string
|
||||||
|
wfs *WFS
|
||||||
|
entry *filer_pb.Entry
|
||||||
|
parent *Directory
|
||||||
|
id uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dir *Directory) FullPath() string {
|
||||||
|
var parts []string
|
||||||
|
for p := dir; p != nil; p = p.parent {
|
||||||
|
if strings.HasPrefix(p.name, "/") {
|
||||||
|
if len(p.name) > 1 {
|
||||||
|
parts = append(parts, p.name[1:])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
parts = append(parts, p.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(parts) == 0 {
|
||||||
|
return "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
for i := len(parts) - 1; i >= 0; i-- {
|
||||||
|
buf.WriteString("/")
|
||||||
|
buf.WriteString(parts[i])
|
||||||
|
}
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/mount/meta_cache"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fs"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"math"
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = fs.NodeReaddirer(&Directory{})
|
||||||
|
var _ = fs.NodeGetattrer(&Directory{})
|
||||||
|
|
||||||
|
func (dir *Directory) Getattr(ctx context.Context, fh fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
|
||||||
|
out.Mode = 0755
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dir *Directory) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
||||||
|
|
||||||
|
dirPath := util.FullPath(dir.FullPath())
|
||||||
|
glog.V(4).Infof("Readdir %s", dirPath)
|
||||||
|
|
||||||
|
sourceChan := make(chan fuse.DirEntry, 64)
|
||||||
|
|
||||||
|
stream := newDirectoryListStream(sourceChan)
|
||||||
|
|
||||||
|
processEachEntryFn := func(entry *filer.Entry, isLast bool) {
|
||||||
|
sourceChan <- fuse.DirEntry{
|
||||||
|
Mode: uint32(entry.Mode),
|
||||||
|
Name: entry.Name(),
|
||||||
|
Ino: dirPath.Child(entry.Name()).AsInode(os.ModeDir),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := meta_cache.EnsureVisited(dir.wfs.metaCache, dir.wfs, dirPath); err != nil {
|
||||||
|
glog.Errorf("dir ReadDirAll %s: %v", dirPath, err)
|
||||||
|
return nil, fs.ToErrno(os.ErrInvalid)
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
dir.wfs.metaCache.ListDirectoryEntries(context.Background(), dirPath, "", false, int64(math.MaxInt32), func(entry *filer.Entry) bool {
|
||||||
|
processEachEntryFn(entry, false)
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
close(sourceChan)
|
||||||
|
}()
|
||||||
|
|
||||||
|
return stream, fs.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ = fs.DirStream(&DirectoryListStream{})
|
||||||
|
|
||||||
|
type DirectoryListStream struct {
|
||||||
|
next fuse.DirEntry
|
||||||
|
sourceChan chan fuse.DirEntry
|
||||||
|
isStarted bool
|
||||||
|
hasNext bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func newDirectoryListStream(ch chan fuse.DirEntry) *DirectoryListStream {
|
||||||
|
return &DirectoryListStream{
|
||||||
|
sourceChan: ch,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *DirectoryListStream) HasNext() bool {
|
||||||
|
if !i.isStarted {
|
||||||
|
i.next, i.hasNext = <-i.sourceChan
|
||||||
|
i.isStarted = true
|
||||||
|
}
|
||||||
|
return i.hasNext
|
||||||
|
}
|
||||||
|
func (i *DirectoryListStream) Next() (fuse.DirEntry, syscall.Errno) {
|
||||||
|
t := i.next
|
||||||
|
i.next, i.hasNext = <-i.sourceChan
|
||||||
|
return t, fs.OK
|
||||||
|
}
|
||||||
|
func (i *DirectoryListStream) Close() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filesys/page_writer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"io"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ChunkedDirtyPages struct {
|
||||||
|
fh *FileHandle
|
||||||
|
writeWaitGroup sync.WaitGroup
|
||||||
|
lastErr error
|
||||||
|
collection string
|
||||||
|
replication string
|
||||||
|
uploadPipeline *page_writer.UploadPipeline
|
||||||
|
hasWrites bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ = page_writer.DirtyPages(&ChunkedDirtyPages{})
|
||||||
|
)
|
||||||
|
|
||||||
|
func newMemoryChunkPages(fh *FileHandle, chunkSize int64) *ChunkedDirtyPages {
|
||||||
|
|
||||||
|
dirtyPages := &ChunkedDirtyPages{
|
||||||
|
fh: fh,
|
||||||
|
}
|
||||||
|
|
||||||
|
dirtyPages.uploadPipeline = page_writer.NewUploadPipeline(fh.wfs.concurrentWriters, chunkSize, dirtyPages.saveChunkedFileIntevalToStorage, fh.wfs.option.ConcurrentWriters)
|
||||||
|
|
||||||
|
return dirtyPages
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pages *ChunkedDirtyPages) AddPage(offset int64, data []byte) {
|
||||||
|
pages.hasWrites = true
|
||||||
|
|
||||||
|
glog.V(4).Infof("%v memory AddPage [%d, %d)", pages.fh, offset, offset+int64(len(data)))
|
||||||
|
pages.uploadPipeline.SaveDataAt(data, offset)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pages *ChunkedDirtyPages) FlushData() error {
|
||||||
|
if !pages.hasWrites {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
pages.uploadPipeline.FlushAll()
|
||||||
|
if pages.lastErr != nil {
|
||||||
|
return fmt.Errorf("flush data: %v", pages.lastErr)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pages *ChunkedDirtyPages) ReadDirtyDataAt(data []byte, startOffset int64) (maxStop int64) {
|
||||||
|
if !pages.hasWrites {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return pages.uploadPipeline.MaybeReadDataAt(data, startOffset)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pages *ChunkedDirtyPages) GetStorageOptions() (collection, replication string) {
|
||||||
|
return pages.collection, pages.replication
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pages *ChunkedDirtyPages) saveChunkedFileIntevalToStorage(reader io.Reader, offset int64, size int64, cleanupFn func()) {
|
||||||
|
|
||||||
|
mtime := time.Now().UnixNano()
|
||||||
|
defer cleanupFn()
|
||||||
|
|
||||||
|
fileFullPath := pages.fh.FullPath()
|
||||||
|
fileName := fileFullPath.Name()
|
||||||
|
chunk, collection, replication, err := pages.fh.wfs.saveDataAsChunk(fileFullPath)(reader, fileName, offset)
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("%v saveToStorage [%d,%d): %v", fileFullPath, offset, offset+size, err)
|
||||||
|
pages.lastErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
chunk.Mtime = mtime
|
||||||
|
pages.collection, pages.replication = collection, replication
|
||||||
|
pages.fh.addChunks([]*filer_pb.FileChunk{chunk})
|
||||||
|
pages.fh.entryViewCache = nil
|
||||||
|
glog.V(3).Infof("%v saveToStorage %s [%d,%d)", fileFullPath, chunk.FileId, offset, offset+size)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pages ChunkedDirtyPages) Destroy() {
|
||||||
|
pages.uploadPipeline.Shutdown()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pages *ChunkedDirtyPages) LockForRead(startOffset, stopOffset int64) {
|
||||||
|
pages.uploadPipeline.LockForRead(startOffset, stopOffset)
|
||||||
|
}
|
||||||
|
func (pages *ChunkedDirtyPages) UnlockForRead(startOffset, stopOffset int64) {
|
||||||
|
pages.uploadPipeline.UnlockForRead(startOffset, stopOffset)
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"io"
|
||||||
|
"sort"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FileHandleId uint64
|
||||||
|
|
||||||
|
type FileHandle struct {
|
||||||
|
fh FileHandleId
|
||||||
|
counter int64
|
||||||
|
entry *filer_pb.Entry
|
||||||
|
chunkAddLock sync.Mutex
|
||||||
|
inode uint64
|
||||||
|
wfs *WFS
|
||||||
|
|
||||||
|
// cache file has been written to
|
||||||
|
dirtyMetadata bool
|
||||||
|
dirtyPages *PageWriter
|
||||||
|
entryViewCache []filer.VisibleInterval
|
||||||
|
reader io.ReaderAt
|
||||||
|
contentType string
|
||||||
|
handle uint64
|
||||||
|
sync.Mutex
|
||||||
|
|
||||||
|
isDeleted bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func newFileHandle(wfs *WFS, handleId FileHandleId, inode uint64, entry *filer_pb.Entry) *FileHandle {
|
||||||
|
fh := &FileHandle{
|
||||||
|
fh: handleId,
|
||||||
|
counter: 1,
|
||||||
|
inode: inode,
|
||||||
|
wfs: wfs,
|
||||||
|
}
|
||||||
|
// dirtyPages: newContinuousDirtyPages(file, writeOnly),
|
||||||
|
fh.dirtyPages = newPageWriter(fh, wfs.option.ChunkSizeLimit)
|
||||||
|
if entry != nil {
|
||||||
|
entry.Attributes.FileSize = filer.FileSize(entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fh
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fh *FileHandle) FullPath() util.FullPath {
|
||||||
|
return fh.wfs.inodeToPath.GetPath(fh.inode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fh *FileHandle) addChunks(chunks []*filer_pb.FileChunk) {
|
||||||
|
|
||||||
|
// find the earliest incoming chunk
|
||||||
|
newChunks := chunks
|
||||||
|
earliestChunk := newChunks[0]
|
||||||
|
for i := 1; i < len(newChunks); i++ {
|
||||||
|
if lessThan(earliestChunk, newChunks[i]) {
|
||||||
|
earliestChunk = newChunks[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if fh.entry == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// pick out-of-order chunks from existing chunks
|
||||||
|
for _, chunk := range fh.entry.Chunks {
|
||||||
|
if lessThan(earliestChunk, chunk) {
|
||||||
|
chunks = append(chunks, chunk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort incoming chunks
|
||||||
|
sort.Slice(chunks, func(i, j int) bool {
|
||||||
|
return lessThan(chunks[i], chunks[j])
|
||||||
|
})
|
||||||
|
|
||||||
|
glog.V(4).Infof("%s existing %d chunks adds %d more", fh.FullPath(), len(fh.entry.Chunks), len(chunks))
|
||||||
|
|
||||||
|
fh.chunkAddLock.Lock()
|
||||||
|
fh.entry.Chunks = append(fh.entry.Chunks, newChunks...)
|
||||||
|
fh.entryViewCache = nil
|
||||||
|
fh.chunkAddLock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func lessThan(a, b *filer_pb.FileChunk) bool {
|
||||||
|
if a.Mtime == b.Mtime {
|
||||||
|
return a.Fid.FileKey < b.Fid.FileKey
|
||||||
|
}
|
||||||
|
return a.Mtime < b.Mtime
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FileHandleToInode struct {
|
||||||
|
sync.RWMutex
|
||||||
|
nextFh FileHandleId
|
||||||
|
inode2fh map[uint64]*FileHandle
|
||||||
|
fh2inode map[FileHandleId]uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFileHandleToInode() *FileHandleToInode {
|
||||||
|
return &FileHandleToInode{
|
||||||
|
inode2fh: make(map[uint64]*FileHandle),
|
||||||
|
fh2inode: make(map[FileHandleId]uint64),
|
||||||
|
nextFh: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *FileHandleToInode) GetFileHandle(fh FileHandleId) *FileHandle {
|
||||||
|
i.RLock()
|
||||||
|
defer i.RUnlock()
|
||||||
|
inode, found := i.fh2inode[fh]
|
||||||
|
if found {
|
||||||
|
return i.inode2fh[inode]
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *FileHandleToInode) FindFileHandle(inode uint64) (fh *FileHandle, found bool) {
|
||||||
|
i.RLock()
|
||||||
|
defer i.RUnlock()
|
||||||
|
fh, found = i.inode2fh[inode]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *FileHandleToInode) AcquireFileHandle(wfs *WFS, inode uint64, entry *filer_pb.Entry) *FileHandle {
|
||||||
|
i.Lock()
|
||||||
|
defer i.Unlock()
|
||||||
|
fh, found := i.inode2fh[inode]
|
||||||
|
if !found {
|
||||||
|
fh = newFileHandle(wfs, i.nextFh, inode, entry)
|
||||||
|
i.nextFh++
|
||||||
|
i.inode2fh[inode] = fh
|
||||||
|
i.fh2inode[fh.fh] = inode
|
||||||
|
} else {
|
||||||
|
fh.counter++
|
||||||
|
}
|
||||||
|
return fh
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *FileHandleToInode) ReleaseByInode(inode uint64) {
|
||||||
|
i.Lock()
|
||||||
|
defer i.Unlock()
|
||||||
|
fh, found := i.inode2fh[inode]
|
||||||
|
if found {
|
||||||
|
fh.counter--
|
||||||
|
if fh.counter <= 0 {
|
||||||
|
delete(i.inode2fh, inode)
|
||||||
|
delete(i.fh2inode, fh.fh)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (i *FileHandleToInode) ReleaseByHandle(fh FileHandleId) {
|
||||||
|
i.Lock()
|
||||||
|
defer i.Unlock()
|
||||||
|
inode, found := i.fh2inode[fh]
|
||||||
|
if found {
|
||||||
|
fhHandle, fhFound := i.inode2fh[inode]
|
||||||
|
if !fhFound {
|
||||||
|
delete(i.fh2inode, fh)
|
||||||
|
} else {
|
||||||
|
fhHandle.counter--
|
||||||
|
if fhHandle.counter <= 0 {
|
||||||
|
delete(i.inode2fh, inode)
|
||||||
|
delete(i.fh2inode, fhHandle.fh)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"io"
|
||||||
|
"math"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (fh *FileHandle) lockForRead(startOffset int64, size int) {
|
||||||
|
fh.dirtyPages.LockForRead(startOffset, startOffset+int64(size))
|
||||||
|
}
|
||||||
|
func (fh *FileHandle) unlockForRead(startOffset int64, size int) {
|
||||||
|
fh.dirtyPages.UnlockForRead(startOffset, startOffset+int64(size))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fh *FileHandle) readFromDirtyPages(buff []byte, startOffset int64) (maxStop int64) {
|
||||||
|
maxStop = fh.dirtyPages.ReadDirtyDataAt(buff, startOffset)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) {
|
||||||
|
|
||||||
|
fileFullPath := fh.FullPath()
|
||||||
|
|
||||||
|
entry := fh.entry
|
||||||
|
if entry == nil {
|
||||||
|
return 0, io.EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
if entry.IsInRemoteOnly() {
|
||||||
|
glog.V(4).Infof("download remote entry %s", fileFullPath)
|
||||||
|
newEntry, err := fh.downloadRemoteEntry(entry)
|
||||||
|
if err != nil {
|
||||||
|
glog.V(1).Infof("download remote entry %s: %v", fileFullPath, err)
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
entry = newEntry
|
||||||
|
}
|
||||||
|
|
||||||
|
fileSize := int64(filer.FileSize(entry))
|
||||||
|
|
||||||
|
if fileSize == 0 {
|
||||||
|
glog.V(1).Infof("empty fh %v", fileFullPath)
|
||||||
|
return 0, io.EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
if offset+int64(len(buff)) <= int64(len(entry.Content)) {
|
||||||
|
totalRead := copy(buff, entry.Content[offset:])
|
||||||
|
glog.V(4).Infof("file handle read cached %s [%d,%d] %d", fileFullPath, offset, offset+int64(totalRead), totalRead)
|
||||||
|
return int64(totalRead), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var chunkResolveErr error
|
||||||
|
if fh.entryViewCache == nil {
|
||||||
|
fh.entryViewCache, chunkResolveErr = filer.NonOverlappingVisibleIntervals(fh.wfs.LookupFn(), entry.Chunks, 0, math.MaxInt64)
|
||||||
|
if chunkResolveErr != nil {
|
||||||
|
return 0, fmt.Errorf("fail to resolve chunk manifest: %v", chunkResolveErr)
|
||||||
|
}
|
||||||
|
fh.reader = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
reader := fh.reader
|
||||||
|
if reader == nil {
|
||||||
|
chunkViews := filer.ViewFromVisibleIntervals(fh.entryViewCache, 0, math.MaxInt64)
|
||||||
|
glog.V(4).Infof("file handle read %s [%d,%d) from %d views", fileFullPath, offset, offset+int64(len(buff)), len(chunkViews))
|
||||||
|
for _, chunkView := range chunkViews {
|
||||||
|
glog.V(4).Infof(" read %s [%d,%d) from chunk %+v", fileFullPath, chunkView.LogicOffset, chunkView.LogicOffset+int64(chunkView.Size), chunkView.FileId)
|
||||||
|
}
|
||||||
|
reader = filer.NewChunkReaderAtFromClient(fh.wfs.LookupFn(), chunkViews, fh.wfs.chunkCache, fileSize)
|
||||||
|
}
|
||||||
|
fh.reader = reader
|
||||||
|
|
||||||
|
totalRead, err := reader.ReadAt(buff, offset)
|
||||||
|
|
||||||
|
if err != nil && err != io.EOF {
|
||||||
|
glog.Errorf("file handle read %s: %v", fileFullPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(4).Infof("file handle read %s [%d,%d] %d : %v", fileFullPath, offset, offset+int64(totalRead), totalRead, err)
|
||||||
|
|
||||||
|
return int64(totalRead), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fh *FileHandle) downloadRemoteEntry(entry *filer_pb.Entry) (*filer_pb.Entry, error) {
|
||||||
|
|
||||||
|
fileFullPath := fh.FullPath()
|
||||||
|
dir, _ := fileFullPath.DirAndName()
|
||||||
|
|
||||||
|
err := fh.wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
|
request := &filer_pb.CacheRemoteObjectToLocalClusterRequest{
|
||||||
|
Directory: string(dir),
|
||||||
|
Name: entry.Name,
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(4).Infof("download entry: %v", request)
|
||||||
|
resp, err := client.CacheRemoteObjectToLocalCluster(context.Background(), request)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("CacheRemoteObjectToLocalCluster file %s: %v", fileFullPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
entry = resp.Entry
|
||||||
|
|
||||||
|
fh.wfs.metaCache.InsertEntry(context.Background(), filer.FromPbEntry(request.Directory, resp.Entry))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
return entry, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
type InodeToPath struct {
|
||||||
|
sync.RWMutex
|
||||||
|
nextInodeId uint64
|
||||||
|
inode2path map[uint64]*InodeEntry
|
||||||
|
path2inode map[util.FullPath]uint64
|
||||||
|
}
|
||||||
|
type InodeEntry struct {
|
||||||
|
util.FullPath
|
||||||
|
nlookup uint64
|
||||||
|
isDirectory bool
|
||||||
|
isChildrenCached bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewInodeToPath() *InodeToPath {
|
||||||
|
t := &InodeToPath{
|
||||||
|
inode2path: make(map[uint64]*InodeEntry),
|
||||||
|
path2inode: make(map[util.FullPath]uint64),
|
||||||
|
nextInodeId: 2, // the root inode id is 1
|
||||||
|
}
|
||||||
|
t.inode2path[1] = &InodeEntry{"/", 1, true, false}
|
||||||
|
t.path2inode["/"] = 1
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InodeToPath) Lookup(path util.FullPath, isDirectory bool) uint64 {
|
||||||
|
i.Lock()
|
||||||
|
defer i.Unlock()
|
||||||
|
inode, found := i.path2inode[path]
|
||||||
|
if !found {
|
||||||
|
inode = i.nextInodeId
|
||||||
|
i.nextInodeId++
|
||||||
|
i.path2inode[path] = inode
|
||||||
|
i.inode2path[inode] = &InodeEntry{path, 1, isDirectory, false}
|
||||||
|
} else {
|
||||||
|
i.inode2path[inode].nlookup++
|
||||||
|
}
|
||||||
|
return inode
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InodeToPath) GetInode(path util.FullPath) uint64 {
|
||||||
|
if path == "/" {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
i.Lock()
|
||||||
|
defer i.Unlock()
|
||||||
|
inode, found := i.path2inode[path]
|
||||||
|
if !found {
|
||||||
|
// glog.Fatalf("GetInode unknown inode for %s", path)
|
||||||
|
// this could be the parent for mount point
|
||||||
|
}
|
||||||
|
return inode
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InodeToPath) GetPath(inode uint64) util.FullPath {
|
||||||
|
i.RLock()
|
||||||
|
defer i.RUnlock()
|
||||||
|
path, found := i.inode2path[inode]
|
||||||
|
if !found {
|
||||||
|
glog.Fatalf("not found inode %d", inode)
|
||||||
|
}
|
||||||
|
return path.FullPath
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InodeToPath) HasPath(path util.FullPath) bool {
|
||||||
|
i.RLock()
|
||||||
|
defer i.RUnlock()
|
||||||
|
_, found := i.path2inode[path]
|
||||||
|
return found
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InodeToPath) MarkChildrenCached(fullpath util.FullPath) {
|
||||||
|
i.RLock()
|
||||||
|
defer i.RUnlock()
|
||||||
|
inode, found := i.path2inode[fullpath]
|
||||||
|
if !found {
|
||||||
|
glog.Fatalf("MarkChildrenCached not found inode %v", fullpath)
|
||||||
|
}
|
||||||
|
path, found := i.inode2path[inode]
|
||||||
|
path.isChildrenCached = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InodeToPath) IsChildrenCached(fullpath util.FullPath) bool {
|
||||||
|
i.RLock()
|
||||||
|
defer i.RUnlock()
|
||||||
|
inode, found := i.path2inode[fullpath]
|
||||||
|
if !found {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
path, found := i.inode2path[inode]
|
||||||
|
if found {
|
||||||
|
return path.isChildrenCached
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InodeToPath) HasInode(inode uint64) bool {
|
||||||
|
if inode == 1 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
i.RLock()
|
||||||
|
defer i.RUnlock()
|
||||||
|
_, found := i.inode2path[inode]
|
||||||
|
return found
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InodeToPath) RemovePath(path util.FullPath) {
|
||||||
|
i.Lock()
|
||||||
|
defer i.Unlock()
|
||||||
|
inode, found := i.path2inode[path]
|
||||||
|
if found {
|
||||||
|
delete(i.path2inode, path)
|
||||||
|
delete(i.inode2path, inode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InodeToPath) MovePath(sourcePath, targetPath util.FullPath) {
|
||||||
|
i.Lock()
|
||||||
|
defer i.Unlock()
|
||||||
|
sourceInode, sourceFound := i.path2inode[sourcePath]
|
||||||
|
targetInode, targetFound := i.path2inode[targetPath]
|
||||||
|
if sourceFound {
|
||||||
|
delete(i.path2inode, sourcePath)
|
||||||
|
i.path2inode[targetPath] = sourceInode
|
||||||
|
} else {
|
||||||
|
// it is possible some source folder items has not been visited before
|
||||||
|
// so no need to worry about their source inodes
|
||||||
|
return
|
||||||
|
}
|
||||||
|
i.inode2path[sourceInode].FullPath = targetPath
|
||||||
|
if targetFound {
|
||||||
|
delete(i.inode2path, targetInode)
|
||||||
|
} else {
|
||||||
|
i.inode2path[sourceInode].nlookup++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InodeToPath) Forget(inode, nlookup uint64, onForgetDir func(dir util.FullPath)) {
|
||||||
|
i.Lock()
|
||||||
|
path, found := i.inode2path[inode]
|
||||||
|
if found {
|
||||||
|
path.nlookup -= nlookup
|
||||||
|
if path.nlookup <= 0 {
|
||||||
|
delete(i.path2inode, path.FullPath)
|
||||||
|
delete(i.inode2path, inode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i.Unlock()
|
||||||
|
if found {
|
||||||
|
if path.isDirectory && onForgetDir != nil {
|
||||||
|
onForgetDir(path.FullPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package meta_cache
|
||||||
|
|
||||||
|
import "github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ = util.Configuration(&cacheConfig{})
|
||||||
|
)
|
||||||
|
|
||||||
|
// implementing util.Configuraion
|
||||||
|
type cacheConfig struct {
|
||||||
|
dir string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c cacheConfig) GetString(key string) string {
|
||||||
|
return c.dir
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c cacheConfig) GetBool(key string) bool {
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c cacheConfig) GetInt(key string) int {
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c cacheConfig) GetStringSlice(key string) []string {
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c cacheConfig) SetDefault(key string, value interface{}) {
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package meta_cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UidGidMapper struct {
|
||||||
|
uidMapper *IdMapper
|
||||||
|
gidMapper *IdMapper
|
||||||
|
}
|
||||||
|
|
||||||
|
type IdMapper struct {
|
||||||
|
localToFiler map[uint32]uint32
|
||||||
|
filerToLocal map[uint32]uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
// UidGidMapper translates local uid/gid to filer uid/gid
|
||||||
|
// The local storage always persists the same as the filer.
|
||||||
|
// The local->filer translation happens when updating the filer first and later saving to meta_cache.
|
||||||
|
// And filer->local happens when reading from the meta_cache.
|
||||||
|
func NewUidGidMapper(uidPairsStr, gidPairStr string) (*UidGidMapper, error) {
|
||||||
|
uidMapper, err := newIdMapper(uidPairsStr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
gidMapper, err := newIdMapper(gidPairStr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &UidGidMapper{
|
||||||
|
uidMapper: uidMapper,
|
||||||
|
gidMapper: gidMapper,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *UidGidMapper) LocalToFiler(uid, gid uint32) (uint32, uint32) {
|
||||||
|
return m.uidMapper.LocalToFiler(uid), m.gidMapper.LocalToFiler(gid)
|
||||||
|
}
|
||||||
|
func (m *UidGidMapper) FilerToLocal(uid, gid uint32) (uint32, uint32) {
|
||||||
|
return m.uidMapper.FilerToLocal(uid), m.gidMapper.FilerToLocal(gid)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *IdMapper) LocalToFiler(id uint32) uint32 {
|
||||||
|
value, found := m.localToFiler[id]
|
||||||
|
if found {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
func (m *IdMapper) FilerToLocal(id uint32) uint32 {
|
||||||
|
value, found := m.filerToLocal[id]
|
||||||
|
if found {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
func newIdMapper(pairsStr string) (*IdMapper, error) {
|
||||||
|
|
||||||
|
localToFiler, filerToLocal, err := parseUint32Pairs(pairsStr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &IdMapper{
|
||||||
|
localToFiler: localToFiler,
|
||||||
|
filerToLocal: filerToLocal,
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseUint32Pairs(pairsStr string) (localToFiler, filerToLocal map[uint32]uint32, err error) {
|
||||||
|
|
||||||
|
if pairsStr == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
localToFiler = make(map[uint32]uint32)
|
||||||
|
filerToLocal = make(map[uint32]uint32)
|
||||||
|
for _, pairStr := range strings.Split(pairsStr, ",") {
|
||||||
|
pair := strings.Split(pairStr, ":")
|
||||||
|
localUidStr, filerUidStr := pair[0], pair[1]
|
||||||
|
localUid, localUidErr := strconv.Atoi(localUidStr)
|
||||||
|
if localUidErr != nil {
|
||||||
|
err = fmt.Errorf("failed to parse local %s: %v", localUidStr, localUidErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
filerUid, filerUidErr := strconv.Atoi(filerUidStr)
|
||||||
|
if filerUidErr != nil {
|
||||||
|
err = fmt.Errorf("failed to parse remote %s: %v", filerUidStr, filerUidErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
localToFiler[uint32(localUid)] = uint32(filerUid)
|
||||||
|
filerToLocal[uint32(filerUid)] = uint32(localUid)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package meta_cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer/leveldb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// need to have logic similar to FilerStoreWrapper
|
||||||
|
// e.g. fill fileId field for chunks
|
||||||
|
|
||||||
|
type MetaCache struct {
|
||||||
|
localStore filer.VirtualFilerStore
|
||||||
|
// sync.RWMutex
|
||||||
|
uidGidMapper *UidGidMapper
|
||||||
|
markCachedFn func(fullpath util.FullPath)
|
||||||
|
isCachedFn func(fullpath util.FullPath) bool
|
||||||
|
invalidateFunc func(fullpath util.FullPath, entry *filer_pb.Entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMetaCache(dbFolder string, uidGidMapper *UidGidMapper, markCachedFn func(path util.FullPath), isCachedFn func(path util.FullPath) bool, invalidateFunc func(util.FullPath, *filer_pb.Entry)) *MetaCache {
|
||||||
|
return &MetaCache{
|
||||||
|
localStore: openMetaStore(dbFolder),
|
||||||
|
markCachedFn: markCachedFn,
|
||||||
|
isCachedFn: isCachedFn,
|
||||||
|
uidGidMapper: uidGidMapper,
|
||||||
|
invalidateFunc: func(fullpath util.FullPath, entry *filer_pb.Entry) {
|
||||||
|
invalidateFunc(fullpath, entry)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func openMetaStore(dbFolder string) filer.VirtualFilerStore {
|
||||||
|
|
||||||
|
os.RemoveAll(dbFolder)
|
||||||
|
os.MkdirAll(dbFolder, 0755)
|
||||||
|
|
||||||
|
store := &leveldb.LevelDBStore{}
|
||||||
|
config := &cacheConfig{
|
||||||
|
dir: dbFolder,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := store.Initialize(config, ""); err != nil {
|
||||||
|
glog.Fatalf("Failed to initialize metadata cache store for %s: %+v", store.GetName(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return filer.NewFilerStoreWrapper(store)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) InsertEntry(ctx context.Context, entry *filer.Entry) error {
|
||||||
|
//mc.Lock()
|
||||||
|
//defer mc.Unlock()
|
||||||
|
return mc.doInsertEntry(ctx, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) doInsertEntry(ctx context.Context, entry *filer.Entry) error {
|
||||||
|
return mc.localStore.InsertEntry(ctx, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) AtomicUpdateEntryFromFiler(ctx context.Context, oldPath util.FullPath, newEntry *filer.Entry) error {
|
||||||
|
//mc.Lock()
|
||||||
|
//defer mc.Unlock()
|
||||||
|
|
||||||
|
oldDir, _ := oldPath.DirAndName()
|
||||||
|
if mc.isCachedFn(util.FullPath(oldDir)) {
|
||||||
|
if oldPath != "" {
|
||||||
|
if newEntry != nil && oldPath == newEntry.FullPath {
|
||||||
|
// skip the unnecessary deletion
|
||||||
|
// leave the update to the following InsertEntry operation
|
||||||
|
} else {
|
||||||
|
glog.V(3).Infof("DeleteEntry %s", oldPath)
|
||||||
|
if err := mc.localStore.DeleteEntry(ctx, oldPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// println("unknown old directory:", oldDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
if newEntry != nil {
|
||||||
|
newDir, _ := newEntry.DirAndName()
|
||||||
|
if mc.isCachedFn(util.FullPath(newDir)) {
|
||||||
|
glog.V(3).Infof("InsertEntry %s/%s", newDir, newEntry.Name())
|
||||||
|
if err := mc.localStore.InsertEntry(ctx, newEntry); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) UpdateEntry(ctx context.Context, entry *filer.Entry) error {
|
||||||
|
//mc.Lock()
|
||||||
|
//defer mc.Unlock()
|
||||||
|
return mc.localStore.UpdateEntry(ctx, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) FindEntry(ctx context.Context, fp util.FullPath) (entry *filer.Entry, err error) {
|
||||||
|
//mc.RLock()
|
||||||
|
//defer mc.RUnlock()
|
||||||
|
entry, err = mc.localStore.FindEntry(ctx, fp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mc.mapIdFromFilerToLocal(entry)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) DeleteEntry(ctx context.Context, fp util.FullPath) (err error) {
|
||||||
|
//mc.Lock()
|
||||||
|
//defer mc.Unlock()
|
||||||
|
return mc.localStore.DeleteEntry(ctx, fp)
|
||||||
|
}
|
||||||
|
func (mc *MetaCache) DeleteFolderChildren(ctx context.Context, fp util.FullPath) (err error) {
|
||||||
|
//mc.Lock()
|
||||||
|
//defer mc.Unlock()
|
||||||
|
return mc.localStore.DeleteFolderChildren(ctx, fp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) ListDirectoryEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int64, eachEntryFunc filer.ListEachEntryFunc) error {
|
||||||
|
//mc.RLock()
|
||||||
|
//defer mc.RUnlock()
|
||||||
|
|
||||||
|
if !mc.isCachedFn(dirPath) {
|
||||||
|
// if this request comes after renaming, it should be fine
|
||||||
|
glog.Warningf("unsynchronized dir: %v", dirPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := mc.localStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit, func(entry *filer.Entry) bool {
|
||||||
|
mc.mapIdFromFilerToLocal(entry)
|
||||||
|
return eachEntryFunc(entry)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) Shutdown() {
|
||||||
|
//mc.Lock()
|
||||||
|
//defer mc.Unlock()
|
||||||
|
mc.localStore.Shutdown()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) mapIdFromFilerToLocal(entry *filer.Entry) {
|
||||||
|
entry.Attr.Uid, entry.Attr.Gid = mc.uidGidMapper.FilerToLocal(entry.Attr.Uid, entry.Attr.Gid)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MetaCache) Debug() {
|
||||||
|
if debuggable, ok := mc.localStore.(filer.Debuggable); ok {
|
||||||
|
println("start debugging")
|
||||||
|
debuggable.Debug(os.Stderr)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package meta_cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
func EnsureVisited(mc *MetaCache, client filer_pb.FilerClient, dirPath util.FullPath) error {
|
||||||
|
|
||||||
|
for {
|
||||||
|
|
||||||
|
// the directory children are already cached
|
||||||
|
// so no need for this and upper directories
|
||||||
|
if mc.isCachedFn(dirPath) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := doEnsureVisited(mc, client, dirPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// continue to parent directory
|
||||||
|
if dirPath != "/" {
|
||||||
|
parent, _ := dirPath.DirAndName()
|
||||||
|
dirPath = util.FullPath(parent)
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func doEnsureVisited(mc *MetaCache, client filer_pb.FilerClient, path util.FullPath) error {
|
||||||
|
|
||||||
|
glog.V(4).Infof("ReadDirAllEntries %s ...", path)
|
||||||
|
|
||||||
|
err := util.Retry("ReadDirAllEntries", func() error {
|
||||||
|
return filer_pb.ReadDirAllEntries(client, path, "", func(pbEntry *filer_pb.Entry, isLast bool) error {
|
||||||
|
entry := filer.FromPbEntry(string(path), pbEntry)
|
||||||
|
if IsHiddenSystemEntry(string(path), entry.Name()) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err := mc.doInsertEntry(context.Background(), entry); err != nil {
|
||||||
|
glog.V(0).Infof("read %s: %v", entry.FullPath, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
err = fmt.Errorf("list %s: %v", path, err)
|
||||||
|
}
|
||||||
|
mc.markCachedFn(path)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsHiddenSystemEntry(dir, name string) bool {
|
||||||
|
return dir == "/" && (name == "topics" || name == "etc")
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package meta_cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SubscribeMetaEvents(mc *MetaCache, selfSignature int32, client filer_pb.FilerClient, dir string, lastTsNs int64) error {
|
||||||
|
|
||||||
|
processEventFn := func(resp *filer_pb.SubscribeMetadataResponse) error {
|
||||||
|
message := resp.EventNotification
|
||||||
|
|
||||||
|
for _, sig := range message.Signatures {
|
||||||
|
if sig == selfSignature && selfSignature != 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dir := resp.Directory
|
||||||
|
var oldPath util.FullPath
|
||||||
|
var newEntry *filer.Entry
|
||||||
|
if message.OldEntry != nil {
|
||||||
|
oldPath = util.NewFullPath(dir, message.OldEntry.Name)
|
||||||
|
glog.V(4).Infof("deleting %v", oldPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
if message.NewEntry != nil {
|
||||||
|
if message.NewParentPath != "" {
|
||||||
|
dir = message.NewParentPath
|
||||||
|
}
|
||||||
|
key := util.NewFullPath(dir, message.NewEntry.Name)
|
||||||
|
glog.V(4).Infof("creating %v", key)
|
||||||
|
newEntry = filer.FromPbEntry(dir, message.NewEntry)
|
||||||
|
}
|
||||||
|
err := mc.AtomicUpdateEntryFromFiler(context.Background(), oldPath, newEntry)
|
||||||
|
if err == nil {
|
||||||
|
if message.OldEntry != nil && message.NewEntry != nil {
|
||||||
|
oldKey := util.NewFullPath(resp.Directory, message.OldEntry.Name)
|
||||||
|
mc.invalidateFunc(oldKey, message.OldEntry)
|
||||||
|
if message.OldEntry.Name != message.NewEntry.Name {
|
||||||
|
newKey := util.NewFullPath(dir, message.NewEntry.Name)
|
||||||
|
mc.invalidateFunc(newKey, message.NewEntry)
|
||||||
|
}
|
||||||
|
} else if message.OldEntry == nil && message.NewEntry != nil {
|
||||||
|
// no need to invaalidate
|
||||||
|
} else if message.OldEntry != nil && message.NewEntry == nil {
|
||||||
|
oldKey := util.NewFullPath(resp.Directory, message.OldEntry.Name)
|
||||||
|
mc.invalidateFunc(oldKey, message.OldEntry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
util.RetryForever("followMetaUpdates", func() error {
|
||||||
|
return pb.WithFilerClientFollowMetadata(client, "mount", selfSignature, dir, &lastTsNs, selfSignature, processEventFn, true)
|
||||||
|
}, func(err error) bool {
|
||||||
|
glog.Errorf("follow metadata updates: %v", err)
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filesys/page_writer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PageWriter struct {
|
||||||
|
fh *FileHandle
|
||||||
|
collection string
|
||||||
|
replication string
|
||||||
|
chunkSize int64
|
||||||
|
|
||||||
|
randomWriter page_writer.DirtyPages
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ = page_writer.DirtyPages(&PageWriter{})
|
||||||
|
)
|
||||||
|
|
||||||
|
func newPageWriter(fh *FileHandle, chunkSize int64) *PageWriter {
|
||||||
|
pw := &PageWriter{
|
||||||
|
fh: fh,
|
||||||
|
chunkSize: chunkSize,
|
||||||
|
randomWriter: newMemoryChunkPages(fh, chunkSize),
|
||||||
|
// randomWriter: newTempFileDirtyPages(fh.f, chunkSize),
|
||||||
|
}
|
||||||
|
return pw
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pw *PageWriter) AddPage(offset int64, data []byte) {
|
||||||
|
|
||||||
|
glog.V(4).Infof("%v AddPage [%d, %d)", pw.fh.fh, offset, offset+int64(len(data)))
|
||||||
|
|
||||||
|
chunkIndex := offset / pw.chunkSize
|
||||||
|
for i := chunkIndex; len(data) > 0; i++ {
|
||||||
|
writeSize := min(int64(len(data)), (i+1)*pw.chunkSize-offset)
|
||||||
|
pw.addToOneChunk(i, offset, data[:writeSize])
|
||||||
|
offset += writeSize
|
||||||
|
data = data[writeSize:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pw *PageWriter) addToOneChunk(chunkIndex, offset int64, data []byte) {
|
||||||
|
pw.randomWriter.AddPage(offset, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pw *PageWriter) FlushData() error {
|
||||||
|
return pw.randomWriter.FlushData()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pw *PageWriter) ReadDirtyDataAt(data []byte, offset int64) (maxStop int64) {
|
||||||
|
glog.V(4).Infof("ReadDirtyDataAt %v [%d, %d)", pw.fh.fh, offset, offset+int64(len(data)))
|
||||||
|
|
||||||
|
chunkIndex := offset / pw.chunkSize
|
||||||
|
for i := chunkIndex; len(data) > 0; i++ {
|
||||||
|
readSize := min(int64(len(data)), (i+1)*pw.chunkSize-offset)
|
||||||
|
|
||||||
|
maxStop = pw.randomWriter.ReadDirtyDataAt(data[:readSize], offset)
|
||||||
|
|
||||||
|
offset += readSize
|
||||||
|
data = data[readSize:]
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pw *PageWriter) GetStorageOptions() (collection, replication string) {
|
||||||
|
return pw.randomWriter.GetStorageOptions()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pw *PageWriter) LockForRead(startOffset, stopOffset int64) {
|
||||||
|
pw.randomWriter.LockForRead(startOffset, stopOffset)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pw *PageWriter) UnlockForRead(startOffset, stopOffset int64) {
|
||||||
|
pw.randomWriter.UnlockForRead(startOffset, stopOffset)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pw *PageWriter) Destroy() {
|
||||||
|
pw.randomWriter.Destroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
func max(x, y int64) int64 {
|
||||||
|
if x > y {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
return y
|
||||||
|
}
|
||||||
|
func min(x, y int64) int64 {
|
||||||
|
if x < y {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
return y
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
|
// ChunkWrittenInterval mark one written interval within one page chunk
|
||||||
|
type ChunkWrittenInterval struct {
|
||||||
|
StartOffset int64
|
||||||
|
stopOffset int64
|
||||||
|
prev *ChunkWrittenInterval
|
||||||
|
next *ChunkWrittenInterval
|
||||||
|
}
|
||||||
|
|
||||||
|
func (interval *ChunkWrittenInterval) Size() int64 {
|
||||||
|
return interval.stopOffset - interval.StartOffset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (interval *ChunkWrittenInterval) isComplete(chunkSize int64) bool {
|
||||||
|
return interval.stopOffset-interval.StartOffset == chunkSize
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChunkWrittenIntervalList mark written intervals within one page chunk
|
||||||
|
type ChunkWrittenIntervalList struct {
|
||||||
|
head *ChunkWrittenInterval
|
||||||
|
tail *ChunkWrittenInterval
|
||||||
|
}
|
||||||
|
|
||||||
|
func newChunkWrittenIntervalList() *ChunkWrittenIntervalList {
|
||||||
|
list := &ChunkWrittenIntervalList{
|
||||||
|
head: &ChunkWrittenInterval{
|
||||||
|
StartOffset: -1,
|
||||||
|
stopOffset: -1,
|
||||||
|
},
|
||||||
|
tail: &ChunkWrittenInterval{
|
||||||
|
StartOffset: math.MaxInt64,
|
||||||
|
stopOffset: math.MaxInt64,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
list.head.next = list.tail
|
||||||
|
list.tail.prev = list.head
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
func (list *ChunkWrittenIntervalList) MarkWritten(startOffset, stopOffset int64) {
|
||||||
|
interval := &ChunkWrittenInterval{
|
||||||
|
StartOffset: startOffset,
|
||||||
|
stopOffset: stopOffset,
|
||||||
|
}
|
||||||
|
list.addInterval(interval)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (list *ChunkWrittenIntervalList) IsComplete(chunkSize int64) bool {
|
||||||
|
return list.size() == 1 && list.head.next.isComplete(chunkSize)
|
||||||
|
}
|
||||||
|
func (list *ChunkWrittenIntervalList) WrittenSize() (writtenByteCount int64) {
|
||||||
|
for t := list.head; t != nil; t = t.next {
|
||||||
|
writtenByteCount += t.Size()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (list *ChunkWrittenIntervalList) addInterval(interval *ChunkWrittenInterval) {
|
||||||
|
|
||||||
|
p := list.head
|
||||||
|
for ; p.next != nil && p.next.StartOffset <= interval.StartOffset; p = p.next {
|
||||||
|
}
|
||||||
|
q := list.tail
|
||||||
|
for ; q.prev != nil && q.prev.stopOffset >= interval.stopOffset; q = q.prev {
|
||||||
|
}
|
||||||
|
|
||||||
|
if interval.StartOffset <= p.stopOffset && q.StartOffset <= interval.stopOffset {
|
||||||
|
// merge p and q together
|
||||||
|
p.stopOffset = q.stopOffset
|
||||||
|
unlinkNodesBetween(p, q.next)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if interval.StartOffset <= p.stopOffset {
|
||||||
|
// merge new interval into p
|
||||||
|
p.stopOffset = interval.stopOffset
|
||||||
|
unlinkNodesBetween(p, q)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if q.StartOffset <= interval.stopOffset {
|
||||||
|
// merge new interval into q
|
||||||
|
q.StartOffset = interval.StartOffset
|
||||||
|
unlinkNodesBetween(p, q)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the new interval between p and q
|
||||||
|
unlinkNodesBetween(p, q)
|
||||||
|
p.next = interval
|
||||||
|
interval.prev = p
|
||||||
|
q.prev = interval
|
||||||
|
interval.next = q
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// unlinkNodesBetween remove all nodes after start and before stop, exclusive
|
||||||
|
func unlinkNodesBetween(start *ChunkWrittenInterval, stop *ChunkWrittenInterval) {
|
||||||
|
if start.next == stop {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
start.next.prev = nil
|
||||||
|
start.next = stop
|
||||||
|
stop.prev.next = nil
|
||||||
|
stop.prev = start
|
||||||
|
}
|
||||||
|
|
||||||
|
func (list *ChunkWrittenIntervalList) size() int {
|
||||||
|
var count int
|
||||||
|
for t := list.head; t != nil; t = t.next {
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
return count - 2
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_PageChunkWrittenIntervalList(t *testing.T) {
|
||||||
|
list := newChunkWrittenIntervalList()
|
||||||
|
|
||||||
|
assert.Equal(t, 0, list.size(), "empty list")
|
||||||
|
|
||||||
|
list.MarkWritten(0, 5)
|
||||||
|
assert.Equal(t, 1, list.size(), "one interval")
|
||||||
|
|
||||||
|
list.MarkWritten(0, 5)
|
||||||
|
assert.Equal(t, 1, list.size(), "duplicated interval2")
|
||||||
|
|
||||||
|
list.MarkWritten(95, 100)
|
||||||
|
assert.Equal(t, 2, list.size(), "two intervals")
|
||||||
|
|
||||||
|
list.MarkWritten(50, 60)
|
||||||
|
assert.Equal(t, 3, list.size(), "three intervals")
|
||||||
|
|
||||||
|
list.MarkWritten(50, 55)
|
||||||
|
assert.Equal(t, 3, list.size(), "three intervals merge")
|
||||||
|
|
||||||
|
list.MarkWritten(40, 50)
|
||||||
|
assert.Equal(t, 3, list.size(), "three intervals grow forward")
|
||||||
|
|
||||||
|
list.MarkWritten(50, 65)
|
||||||
|
assert.Equal(t, 3, list.size(), "three intervals grow backward")
|
||||||
|
|
||||||
|
list.MarkWritten(70, 80)
|
||||||
|
assert.Equal(t, 4, list.size(), "four intervals")
|
||||||
|
|
||||||
|
list.MarkWritten(60, 70)
|
||||||
|
assert.Equal(t, 3, list.size(), "three intervals merged")
|
||||||
|
|
||||||
|
list.MarkWritten(59, 71)
|
||||||
|
assert.Equal(t, 3, list.size(), "covered three intervals")
|
||||||
|
|
||||||
|
list.MarkWritten(5, 59)
|
||||||
|
assert.Equal(t, 2, list.size(), "covered two intervals")
|
||||||
|
|
||||||
|
list.MarkWritten(70, 99)
|
||||||
|
assert.Equal(t, 1, list.size(), "covered one intervals")
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
type DirtyPages interface {
|
||||||
|
AddPage(offset int64, data []byte)
|
||||||
|
FlushData() error
|
||||||
|
ReadDirtyDataAt(data []byte, startOffset int64) (maxStop int64)
|
||||||
|
GetStorageOptions() (collection, replication string)
|
||||||
|
Destroy()
|
||||||
|
LockForRead(startOffset, stopOffset int64)
|
||||||
|
UnlockForRead(startOffset, stopOffset int64)
|
||||||
|
}
|
||||||
|
|
||||||
|
func max(x, y int64) int64 {
|
||||||
|
if x > y {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
return y
|
||||||
|
}
|
||||||
|
func min(x, y int64) int64 {
|
||||||
|
if x < y {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
return y
|
||||||
|
}
|
||||||
|
func minInt(x, y int) int {
|
||||||
|
if x < y {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
return y
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SaveToStorageFunc func(reader io.Reader, offset int64, size int64, cleanupFn func())
|
||||||
|
|
||||||
|
type PageChunk interface {
|
||||||
|
FreeResource()
|
||||||
|
WriteDataAt(src []byte, offset int64) (n int)
|
||||||
|
ReadDataAt(p []byte, off int64) (maxStop int64)
|
||||||
|
IsComplete() bool
|
||||||
|
WrittenSize() int64
|
||||||
|
SaveContent(saveFn SaveToStorageFunc)
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util/mem"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ = PageChunk(&MemChunk{})
|
||||||
|
)
|
||||||
|
|
||||||
|
type MemChunk struct {
|
||||||
|
buf []byte
|
||||||
|
usage *ChunkWrittenIntervalList
|
||||||
|
chunkSize int64
|
||||||
|
logicChunkIndex LogicChunkIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMemChunk(logicChunkIndex LogicChunkIndex, chunkSize int64) *MemChunk {
|
||||||
|
return &MemChunk{
|
||||||
|
logicChunkIndex: logicChunkIndex,
|
||||||
|
chunkSize: chunkSize,
|
||||||
|
buf: mem.Allocate(int(chunkSize)),
|
||||||
|
usage: newChunkWrittenIntervalList(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) FreeResource() {
|
||||||
|
mem.Free(mc.buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) WriteDataAt(src []byte, offset int64) (n int) {
|
||||||
|
innerOffset := offset % mc.chunkSize
|
||||||
|
n = copy(mc.buf[innerOffset:], src)
|
||||||
|
mc.usage.MarkWritten(innerOffset, innerOffset+int64(n))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) ReadDataAt(p []byte, off int64) (maxStop int64) {
|
||||||
|
memChunkBaseOffset := int64(mc.logicChunkIndex) * mc.chunkSize
|
||||||
|
for t := mc.usage.head.next; t != mc.usage.tail; t = t.next {
|
||||||
|
logicStart := max(off, int64(mc.logicChunkIndex)*mc.chunkSize+t.StartOffset)
|
||||||
|
logicStop := min(off+int64(len(p)), memChunkBaseOffset+t.stopOffset)
|
||||||
|
if logicStart < logicStop {
|
||||||
|
copy(p[logicStart-off:logicStop-off], mc.buf[logicStart-memChunkBaseOffset:logicStop-memChunkBaseOffset])
|
||||||
|
maxStop = max(maxStop, logicStop)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) IsComplete() bool {
|
||||||
|
return mc.usage.IsComplete(mc.chunkSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) WrittenSize() int64 {
|
||||||
|
return mc.usage.WrittenSize()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MemChunk) SaveContent(saveFn SaveToStorageFunc) {
|
||||||
|
if saveFn == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for t := mc.usage.head.next; t != mc.usage.tail; t = t.next {
|
||||||
|
reader := util.NewBytesReader(mc.buf[t.StartOffset:t.stopOffset])
|
||||||
|
saveFn(reader, int64(mc.logicChunkIndex)*mc.chunkSize+t.StartOffset, t.Size(), func() {
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util/mem"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ = PageChunk(&SwapFileChunk{})
|
||||||
|
)
|
||||||
|
|
||||||
|
type ActualChunkIndex int
|
||||||
|
|
||||||
|
type SwapFile struct {
|
||||||
|
dir string
|
||||||
|
file *os.File
|
||||||
|
logicToActualChunkIndex map[LogicChunkIndex]ActualChunkIndex
|
||||||
|
chunkSize int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type SwapFileChunk struct {
|
||||||
|
swapfile *SwapFile
|
||||||
|
usage *ChunkWrittenIntervalList
|
||||||
|
logicChunkIndex LogicChunkIndex
|
||||||
|
actualChunkIndex ActualChunkIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSwapFile(dir string, chunkSize int64) *SwapFile {
|
||||||
|
return &SwapFile{
|
||||||
|
dir: dir,
|
||||||
|
file: nil,
|
||||||
|
logicToActualChunkIndex: make(map[LogicChunkIndex]ActualChunkIndex),
|
||||||
|
chunkSize: chunkSize,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (sf *SwapFile) FreeResource() {
|
||||||
|
if sf.file != nil {
|
||||||
|
sf.file.Close()
|
||||||
|
os.Remove(sf.file.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sf *SwapFile) NewTempFileChunk(logicChunkIndex LogicChunkIndex) (tc *SwapFileChunk) {
|
||||||
|
if sf.file == nil {
|
||||||
|
var err error
|
||||||
|
sf.file, err = os.CreateTemp(sf.dir, "")
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("create swap file: %v", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
actualChunkIndex, found := sf.logicToActualChunkIndex[logicChunkIndex]
|
||||||
|
if !found {
|
||||||
|
actualChunkIndex = ActualChunkIndex(len(sf.logicToActualChunkIndex))
|
||||||
|
sf.logicToActualChunkIndex[logicChunkIndex] = actualChunkIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
return &SwapFileChunk{
|
||||||
|
swapfile: sf,
|
||||||
|
usage: newChunkWrittenIntervalList(),
|
||||||
|
logicChunkIndex: logicChunkIndex,
|
||||||
|
actualChunkIndex: actualChunkIndex,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) FreeResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) WriteDataAt(src []byte, offset int64) (n int) {
|
||||||
|
innerOffset := offset % sc.swapfile.chunkSize
|
||||||
|
var err error
|
||||||
|
n, err = sc.swapfile.file.WriteAt(src, int64(sc.actualChunkIndex)*sc.swapfile.chunkSize+innerOffset)
|
||||||
|
if err == nil {
|
||||||
|
sc.usage.MarkWritten(innerOffset, innerOffset+int64(n))
|
||||||
|
} else {
|
||||||
|
glog.Errorf("failed to write swap file %s: %v", sc.swapfile.file.Name(), err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) ReadDataAt(p []byte, off int64) (maxStop int64) {
|
||||||
|
chunkStartOffset := int64(sc.logicChunkIndex) * sc.swapfile.chunkSize
|
||||||
|
for t := sc.usage.head.next; t != sc.usage.tail; t = t.next {
|
||||||
|
logicStart := max(off, chunkStartOffset+t.StartOffset)
|
||||||
|
logicStop := min(off+int64(len(p)), chunkStartOffset+t.stopOffset)
|
||||||
|
if logicStart < logicStop {
|
||||||
|
actualStart := logicStart - chunkStartOffset + int64(sc.actualChunkIndex)*sc.swapfile.chunkSize
|
||||||
|
if _, err := sc.swapfile.file.ReadAt(p[logicStart-off:logicStop-off], actualStart); err != nil {
|
||||||
|
glog.Errorf("failed to reading swap file %s: %v", sc.swapfile.file.Name(), err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
maxStop = max(maxStop, logicStop)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) IsComplete() bool {
|
||||||
|
return sc.usage.IsComplete(sc.swapfile.chunkSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) WrittenSize() int64 {
|
||||||
|
return sc.usage.WrittenSize()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SwapFileChunk) SaveContent(saveFn SaveToStorageFunc) {
|
||||||
|
if saveFn == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for t := sc.usage.head.next; t != sc.usage.tail; t = t.next {
|
||||||
|
data := mem.Allocate(int(t.Size()))
|
||||||
|
sc.swapfile.file.ReadAt(data, t.StartOffset+int64(sc.actualChunkIndex)*sc.swapfile.chunkSize)
|
||||||
|
reader := util.NewBytesReader(data)
|
||||||
|
saveFn(reader, int64(sc.logicChunkIndex)*sc.swapfile.chunkSize+t.StartOffset, t.Size(), func() {
|
||||||
|
})
|
||||||
|
mem.Free(data)
|
||||||
|
}
|
||||||
|
sc.usage = newChunkWrittenIntervalList()
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LogicChunkIndex int
|
||||||
|
|
||||||
|
type UploadPipeline struct {
|
||||||
|
filepath util.FullPath
|
||||||
|
ChunkSize int64
|
||||||
|
writableChunks map[LogicChunkIndex]PageChunk
|
||||||
|
writableChunksLock sync.Mutex
|
||||||
|
sealedChunks map[LogicChunkIndex]*SealedChunk
|
||||||
|
sealedChunksLock sync.Mutex
|
||||||
|
uploaders *util.LimitedConcurrentExecutor
|
||||||
|
uploaderCount int32
|
||||||
|
uploaderCountCond *sync.Cond
|
||||||
|
saveToStorageFn SaveToStorageFunc
|
||||||
|
activeReadChunks map[LogicChunkIndex]int
|
||||||
|
activeReadChunksLock sync.Mutex
|
||||||
|
bufferChunkLimit int
|
||||||
|
}
|
||||||
|
|
||||||
|
type SealedChunk struct {
|
||||||
|
chunk PageChunk
|
||||||
|
referenceCounter int // track uploading or reading processes
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SealedChunk) FreeReference(messageOnFree string) {
|
||||||
|
sc.referenceCounter--
|
||||||
|
if sc.referenceCounter == 0 {
|
||||||
|
glog.V(4).Infof("Free sealed chunk: %s", messageOnFree)
|
||||||
|
sc.chunk.FreeResource()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUploadPipeline(writers *util.LimitedConcurrentExecutor, chunkSize int64, saveToStorageFn SaveToStorageFunc, bufferChunkLimit int) *UploadPipeline {
|
||||||
|
return &UploadPipeline{
|
||||||
|
ChunkSize: chunkSize,
|
||||||
|
writableChunks: make(map[LogicChunkIndex]PageChunk),
|
||||||
|
sealedChunks: make(map[LogicChunkIndex]*SealedChunk),
|
||||||
|
uploaders: writers,
|
||||||
|
uploaderCountCond: sync.NewCond(&sync.Mutex{}),
|
||||||
|
saveToStorageFn: saveToStorageFn,
|
||||||
|
activeReadChunks: make(map[LogicChunkIndex]int),
|
||||||
|
bufferChunkLimit: bufferChunkLimit,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) SaveDataAt(p []byte, off int64) (n int) {
|
||||||
|
up.writableChunksLock.Lock()
|
||||||
|
defer up.writableChunksLock.Unlock()
|
||||||
|
|
||||||
|
logicChunkIndex := LogicChunkIndex(off / up.ChunkSize)
|
||||||
|
|
||||||
|
memChunk, found := up.writableChunks[logicChunkIndex]
|
||||||
|
if !found {
|
||||||
|
if len(up.writableChunks) < up.bufferChunkLimit {
|
||||||
|
memChunk = NewMemChunk(logicChunkIndex, up.ChunkSize)
|
||||||
|
} else {
|
||||||
|
fullestChunkIndex, fullness := LogicChunkIndex(-1), int64(0)
|
||||||
|
for lci, mc := range up.writableChunks {
|
||||||
|
chunkFullness := mc.WrittenSize()
|
||||||
|
if fullness < chunkFullness {
|
||||||
|
fullestChunkIndex = lci
|
||||||
|
fullness = chunkFullness
|
||||||
|
}
|
||||||
|
}
|
||||||
|
up.moveToSealed(up.writableChunks[fullestChunkIndex], fullestChunkIndex)
|
||||||
|
delete(up.writableChunks, fullestChunkIndex)
|
||||||
|
fmt.Printf("flush chunk %d with %d bytes written", logicChunkIndex, fullness)
|
||||||
|
memChunk = NewMemChunk(logicChunkIndex, up.ChunkSize)
|
||||||
|
}
|
||||||
|
up.writableChunks[logicChunkIndex] = memChunk
|
||||||
|
}
|
||||||
|
n = memChunk.WriteDataAt(p, off)
|
||||||
|
up.maybeMoveToSealed(memChunk, logicChunkIndex)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) MaybeReadDataAt(p []byte, off int64) (maxStop int64) {
|
||||||
|
logicChunkIndex := LogicChunkIndex(off / up.ChunkSize)
|
||||||
|
|
||||||
|
// read from sealed chunks first
|
||||||
|
up.sealedChunksLock.Lock()
|
||||||
|
sealedChunk, found := up.sealedChunks[logicChunkIndex]
|
||||||
|
if found {
|
||||||
|
sealedChunk.referenceCounter++
|
||||||
|
}
|
||||||
|
up.sealedChunksLock.Unlock()
|
||||||
|
if found {
|
||||||
|
maxStop = sealedChunk.chunk.ReadDataAt(p, off)
|
||||||
|
glog.V(4).Infof("%s read sealed memchunk [%d,%d)", up.filepath, off, maxStop)
|
||||||
|
sealedChunk.FreeReference(fmt.Sprintf("%s finish reading chunk %d", up.filepath, logicChunkIndex))
|
||||||
|
}
|
||||||
|
|
||||||
|
// read from writable chunks last
|
||||||
|
up.writableChunksLock.Lock()
|
||||||
|
defer up.writableChunksLock.Unlock()
|
||||||
|
writableChunk, found := up.writableChunks[logicChunkIndex]
|
||||||
|
if !found {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writableMaxStop := writableChunk.ReadDataAt(p, off)
|
||||||
|
glog.V(4).Infof("%s read writable memchunk [%d,%d)", up.filepath, off, writableMaxStop)
|
||||||
|
maxStop = max(maxStop, writableMaxStop)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) FlushAll() {
|
||||||
|
up.writableChunksLock.Lock()
|
||||||
|
defer up.writableChunksLock.Unlock()
|
||||||
|
|
||||||
|
for logicChunkIndex, memChunk := range up.writableChunks {
|
||||||
|
up.moveToSealed(memChunk, logicChunkIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
up.waitForCurrentWritersToComplete()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) maybeMoveToSealed(memChunk PageChunk, logicChunkIndex LogicChunkIndex) {
|
||||||
|
if memChunk.IsComplete() {
|
||||||
|
up.moveToSealed(memChunk, logicChunkIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) moveToSealed(memChunk PageChunk, logicChunkIndex LogicChunkIndex) {
|
||||||
|
atomic.AddInt32(&up.uploaderCount, 1)
|
||||||
|
glog.V(4).Infof("%s uploaderCount %d ++> %d", up.filepath, up.uploaderCount-1, up.uploaderCount)
|
||||||
|
|
||||||
|
up.sealedChunksLock.Lock()
|
||||||
|
|
||||||
|
if oldMemChunk, found := up.sealedChunks[logicChunkIndex]; found {
|
||||||
|
oldMemChunk.FreeReference(fmt.Sprintf("%s replace chunk %d", up.filepath, logicChunkIndex))
|
||||||
|
}
|
||||||
|
sealedChunk := &SealedChunk{
|
||||||
|
chunk: memChunk,
|
||||||
|
referenceCounter: 1, // default 1 is for uploading process
|
||||||
|
}
|
||||||
|
up.sealedChunks[logicChunkIndex] = sealedChunk
|
||||||
|
delete(up.writableChunks, logicChunkIndex)
|
||||||
|
|
||||||
|
up.sealedChunksLock.Unlock()
|
||||||
|
|
||||||
|
up.uploaders.Execute(func() {
|
||||||
|
// first add to the file chunks
|
||||||
|
sealedChunk.chunk.SaveContent(up.saveToStorageFn)
|
||||||
|
|
||||||
|
// notify waiting process
|
||||||
|
atomic.AddInt32(&up.uploaderCount, -1)
|
||||||
|
glog.V(4).Infof("%s uploaderCount %d --> %d", up.filepath, up.uploaderCount+1, up.uploaderCount)
|
||||||
|
// Lock and Unlock are not required,
|
||||||
|
// but it may signal multiple times during one wakeup,
|
||||||
|
// and the waiting goroutine may miss some of them!
|
||||||
|
up.uploaderCountCond.L.Lock()
|
||||||
|
up.uploaderCountCond.Broadcast()
|
||||||
|
up.uploaderCountCond.L.Unlock()
|
||||||
|
|
||||||
|
// wait for readers
|
||||||
|
for up.IsLocked(logicChunkIndex) {
|
||||||
|
time.Sleep(59 * time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
// then remove from sealed chunks
|
||||||
|
up.sealedChunksLock.Lock()
|
||||||
|
defer up.sealedChunksLock.Unlock()
|
||||||
|
delete(up.sealedChunks, logicChunkIndex)
|
||||||
|
sealedChunk.FreeReference(fmt.Sprintf("%s finished uploading chunk %d", up.filepath, logicChunkIndex))
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) Shutdown() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync/atomic"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (up *UploadPipeline) LockForRead(startOffset, stopOffset int64) {
|
||||||
|
startLogicChunkIndex := LogicChunkIndex(startOffset / up.ChunkSize)
|
||||||
|
stopLogicChunkIndex := LogicChunkIndex(stopOffset / up.ChunkSize)
|
||||||
|
if stopOffset%up.ChunkSize > 0 {
|
||||||
|
stopLogicChunkIndex += 1
|
||||||
|
}
|
||||||
|
up.activeReadChunksLock.Lock()
|
||||||
|
defer up.activeReadChunksLock.Unlock()
|
||||||
|
for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ {
|
||||||
|
if count, found := up.activeReadChunks[i]; found {
|
||||||
|
up.activeReadChunks[i] = count + 1
|
||||||
|
} else {
|
||||||
|
up.activeReadChunks[i] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) UnlockForRead(startOffset, stopOffset int64) {
|
||||||
|
startLogicChunkIndex := LogicChunkIndex(startOffset / up.ChunkSize)
|
||||||
|
stopLogicChunkIndex := LogicChunkIndex(stopOffset / up.ChunkSize)
|
||||||
|
if stopOffset%up.ChunkSize > 0 {
|
||||||
|
stopLogicChunkIndex += 1
|
||||||
|
}
|
||||||
|
up.activeReadChunksLock.Lock()
|
||||||
|
defer up.activeReadChunksLock.Unlock()
|
||||||
|
for i := startLogicChunkIndex; i < stopLogicChunkIndex; i++ {
|
||||||
|
if count, found := up.activeReadChunks[i]; found {
|
||||||
|
if count == 1 {
|
||||||
|
delete(up.activeReadChunks, i)
|
||||||
|
} else {
|
||||||
|
up.activeReadChunks[i] = count - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) IsLocked(logicChunkIndex LogicChunkIndex) bool {
|
||||||
|
up.activeReadChunksLock.Lock()
|
||||||
|
defer up.activeReadChunksLock.Unlock()
|
||||||
|
if count, found := up.activeReadChunks[logicChunkIndex]; found {
|
||||||
|
return count > 0
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (up *UploadPipeline) waitForCurrentWritersToComplete() {
|
||||||
|
up.uploaderCountCond.L.Lock()
|
||||||
|
t := int32(100)
|
||||||
|
for {
|
||||||
|
t = atomic.LoadInt32(&up.uploaderCount)
|
||||||
|
if t <= 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
up.uploaderCountCond.Wait()
|
||||||
|
}
|
||||||
|
up.uploaderCountCond.L.Unlock()
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package page_writer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestUploadPipeline(t *testing.T) {
|
||||||
|
|
||||||
|
uploadPipeline := NewUploadPipeline(nil, 2*1024*1024, nil, 16)
|
||||||
|
|
||||||
|
writeRange(uploadPipeline, 0, 131072)
|
||||||
|
writeRange(uploadPipeline, 131072, 262144)
|
||||||
|
writeRange(uploadPipeline, 262144, 1025536)
|
||||||
|
|
||||||
|
confirmRange(t, uploadPipeline, 0, 1025536)
|
||||||
|
|
||||||
|
writeRange(uploadPipeline, 1025536, 1296896)
|
||||||
|
|
||||||
|
confirmRange(t, uploadPipeline, 1025536, 1296896)
|
||||||
|
|
||||||
|
writeRange(uploadPipeline, 1296896, 2162688)
|
||||||
|
|
||||||
|
confirmRange(t, uploadPipeline, 1296896, 2162688)
|
||||||
|
|
||||||
|
confirmRange(t, uploadPipeline, 1296896, 2162688)
|
||||||
|
}
|
||||||
|
|
||||||
|
// startOff and stopOff must be divided by 4
|
||||||
|
func writeRange(uploadPipeline *UploadPipeline, startOff, stopOff int64) {
|
||||||
|
p := make([]byte, 4)
|
||||||
|
for i := startOff / 4; i < stopOff/4; i += 4 {
|
||||||
|
util.Uint32toBytes(p, uint32(i))
|
||||||
|
uploadPipeline.SaveDataAt(p, i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func confirmRange(t *testing.T, uploadPipeline *UploadPipeline, startOff, stopOff int64) {
|
||||||
|
p := make([]byte, 4)
|
||||||
|
for i := startOff; i < stopOff/4; i += 4 {
|
||||||
|
uploadPipeline.MaybeReadDataAt(p, i)
|
||||||
|
x := util.BytesToUint32(p)
|
||||||
|
if x != uint32(i) {
|
||||||
|
t.Errorf("expecting %d found %d at offset [%d,%d)", i, x, i, i+4)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package unmount
|
||||||
|
|
||||||
|
// Unmount tries to unmount the filesystem mounted at dir.
|
||||||
|
func Unmount(dir string) error {
|
||||||
|
return unmount(dir)
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package unmount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
"os/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
func unmount(dir string) error {
|
||||||
|
cmd := exec.Command("fusermount", "-u", dir)
|
||||||
|
output, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
if len(output) > 0 {
|
||||||
|
output = bytes.TrimRight(output, "\n")
|
||||||
|
msg := err.Error() + ": " + string(output)
|
||||||
|
err = errors.New(msg)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
//go:build !linux
|
||||||
|
// +build !linux
|
||||||
|
|
||||||
|
package unmount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func unmount(dir string) error {
|
||||||
|
err := syscall.Unmount(dir, 0)
|
||||||
|
if err != nil {
|
||||||
|
err = &os.PathError{Op: "unmount", Path: dir, Err: err}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/mount/meta_cache"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util/chunk_cache"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util/grace"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"math/rand"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/hanwen/go-fuse/v2/fs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Option struct {
|
||||||
|
MountDirectory string
|
||||||
|
FilerAddresses []pb.ServerAddress
|
||||||
|
filerIndex int
|
||||||
|
GrpcDialOption grpc.DialOption
|
||||||
|
FilerMountRootPath string
|
||||||
|
Collection string
|
||||||
|
Replication string
|
||||||
|
TtlSec int32
|
||||||
|
DiskType types.DiskType
|
||||||
|
ChunkSizeLimit int64
|
||||||
|
ConcurrentWriters int
|
||||||
|
CacheDir string
|
||||||
|
CacheSizeMB int64
|
||||||
|
DataCenter string
|
||||||
|
Umask os.FileMode
|
||||||
|
|
||||||
|
MountUid uint32
|
||||||
|
MountGid uint32
|
||||||
|
MountMode os.FileMode
|
||||||
|
MountCtime time.Time
|
||||||
|
MountMtime time.Time
|
||||||
|
MountParentInode uint64
|
||||||
|
|
||||||
|
VolumeServerAccess string // how to access volume servers
|
||||||
|
Cipher bool // whether encrypt data on volume server
|
||||||
|
UidGidMapper *meta_cache.UidGidMapper
|
||||||
|
|
||||||
|
uniqueCacheDir string
|
||||||
|
uniqueCacheTempPageDir string
|
||||||
|
}
|
||||||
|
|
||||||
|
type WFS struct {
|
||||||
|
// follow https://github.com/hanwen/go-fuse/blob/master/fuse/api.go
|
||||||
|
fuse.RawFileSystem
|
||||||
|
fs.Inode
|
||||||
|
option *Option
|
||||||
|
metaCache *meta_cache.MetaCache
|
||||||
|
stats statsCache
|
||||||
|
root Directory
|
||||||
|
chunkCache *chunk_cache.TieredChunkCache
|
||||||
|
signature int32
|
||||||
|
concurrentWriters *util.LimitedConcurrentExecutor
|
||||||
|
inodeToPath *InodeToPath
|
||||||
|
fhmap *FileHandleToInode
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSeaweedFileSystem(option *Option) *WFS {
|
||||||
|
wfs := &WFS{
|
||||||
|
RawFileSystem: fuse.NewDefaultRawFileSystem(),
|
||||||
|
option: option,
|
||||||
|
signature: util.RandomInt32(),
|
||||||
|
inodeToPath: NewInodeToPath(),
|
||||||
|
fhmap: NewFileHandleToInode(),
|
||||||
|
}
|
||||||
|
|
||||||
|
wfs.root = Directory{
|
||||||
|
name: "/",
|
||||||
|
wfs: wfs,
|
||||||
|
entry: nil,
|
||||||
|
parent: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
wfs.option.filerIndex = rand.Intn(len(option.FilerAddresses))
|
||||||
|
wfs.option.setupUniqueCacheDirectory()
|
||||||
|
if option.CacheSizeMB > 0 {
|
||||||
|
wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, option.getUniqueCacheDir(), option.CacheSizeMB, 1024*1024)
|
||||||
|
}
|
||||||
|
|
||||||
|
wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.getUniqueCacheDir(), "meta"), option.UidGidMapper, func(path util.FullPath) {
|
||||||
|
wfs.inodeToPath.MarkChildrenCached(path)
|
||||||
|
}, func(path util.FullPath) bool {
|
||||||
|
return wfs.inodeToPath.IsChildrenCached(path)
|
||||||
|
}, func(filePath util.FullPath, entry *filer_pb.Entry) {
|
||||||
|
})
|
||||||
|
grace.OnInterrupt(func() {
|
||||||
|
wfs.metaCache.Shutdown()
|
||||||
|
})
|
||||||
|
|
||||||
|
if wfs.option.ConcurrentWriters > 0 {
|
||||||
|
wfs.concurrentWriters = util.NewLimitedConcurrentExecutor(wfs.option.ConcurrentWriters)
|
||||||
|
}
|
||||||
|
return wfs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) StartBackgroundTasks() {
|
||||||
|
startTime := time.Now()
|
||||||
|
go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs.signature, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) Root() *Directory {
|
||||||
|
return &wfs.root
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) String() string {
|
||||||
|
return "seaweedfs"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) maybeReadEntry(inode uint64) (path util.FullPath, fh *FileHandle, entry *filer_pb.Entry, status fuse.Status) {
|
||||||
|
path = wfs.inodeToPath.GetPath(inode)
|
||||||
|
var found bool
|
||||||
|
if fh, found = wfs.fhmap.FindFileHandle(inode); found {
|
||||||
|
return path, fh, fh.entry, fuse.OK
|
||||||
|
}
|
||||||
|
entry, status = wfs.maybeLoadEntry(path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) maybeLoadEntry(fullpath util.FullPath) (*filer_pb.Entry, fuse.Status) {
|
||||||
|
|
||||||
|
// glog.V(3).Infof("read entry cache miss %s", fullpath)
|
||||||
|
dir, name := fullpath.DirAndName()
|
||||||
|
|
||||||
|
// return a valid entry for the mount root
|
||||||
|
if string(fullpath) == wfs.option.FilerMountRootPath {
|
||||||
|
return &filer_pb.Entry{
|
||||||
|
Name: name,
|
||||||
|
IsDirectory: true,
|
||||||
|
Attributes: &filer_pb.FuseAttributes{
|
||||||
|
Mtime: wfs.option.MountMtime.Unix(),
|
||||||
|
FileMode: uint32(wfs.option.MountMode),
|
||||||
|
Uid: wfs.option.MountUid,
|
||||||
|
Gid: wfs.option.MountGid,
|
||||||
|
Crtime: wfs.option.MountCtime.Unix(),
|
||||||
|
},
|
||||||
|
}, fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
// read from async meta cache
|
||||||
|
meta_cache.EnsureVisited(wfs.metaCache, wfs, util.FullPath(dir))
|
||||||
|
cachedEntry, cacheErr := wfs.metaCache.FindEntry(context.Background(), fullpath)
|
||||||
|
if cacheErr == filer_pb.ErrNotFound {
|
||||||
|
return nil, fuse.ENOENT
|
||||||
|
}
|
||||||
|
return cachedEntry.ToProtoEntry(), fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) LookupFn() wdclient.LookupFileIdFunctionType {
|
||||||
|
if wfs.option.VolumeServerAccess == "filerProxy" {
|
||||||
|
return func(fileId string) (targetUrls []string, err error) {
|
||||||
|
return []string{"http://" + wfs.getCurrentFiler().ToHttpAddress() + "/?proxyChunkId=" + fileId}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filer.LookupFn(wfs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) getCurrentFiler() pb.ServerAddress {
|
||||||
|
return wfs.option.FilerAddresses[wfs.option.filerIndex]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (option *Option) setupUniqueCacheDirectory() {
|
||||||
|
cacheUniqueId := util.Md5String([]byte(option.MountDirectory + string(option.FilerAddresses[0]) + option.FilerMountRootPath + util.Version()))[0:8]
|
||||||
|
option.uniqueCacheDir = path.Join(option.CacheDir, cacheUniqueId)
|
||||||
|
option.uniqueCacheTempPageDir = filepath.Join(option.uniqueCacheDir, "sw")
|
||||||
|
os.MkdirAll(option.uniqueCacheTempPageDir, os.FileMode(0777)&^option.Umask)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (option *Option) getTempFilePageDir() string {
|
||||||
|
return option.uniqueCacheTempPageDir
|
||||||
|
}
|
||||||
|
func (option *Option) getUniqueCacheDir() string {
|
||||||
|
return option.uniqueCacheDir
|
||||||
|
}
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (wfs *WFS) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *fuse.AttrOut) (code fuse.Status) {
|
||||||
|
if input.NodeId == 1 {
|
||||||
|
wfs.setRootAttr(out)
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, entry, status := wfs.maybeReadEntry(input.NodeId)
|
||||||
|
if status != fuse.OK {
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
out.AttrValid = 1
|
||||||
|
wfs.setAttrByPbEntry(&out.Attr, input.NodeId, entry)
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse.Status) {
|
||||||
|
|
||||||
|
path, fh, entry, status := wfs.maybeReadEntry(input.NodeId)
|
||||||
|
if status != fuse.OK {
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
|
||||||
|
if size, ok := input.GetSize(); ok {
|
||||||
|
glog.V(4).Infof("%v setattr set size=%v chunks=%d", path, size, len(entry.Chunks))
|
||||||
|
if size < filer.FileSize(entry) {
|
||||||
|
// fmt.Printf("truncate %v \n", fullPath)
|
||||||
|
var chunks []*filer_pb.FileChunk
|
||||||
|
var truncatedChunks []*filer_pb.FileChunk
|
||||||
|
for _, chunk := range entry.Chunks {
|
||||||
|
int64Size := int64(chunk.Size)
|
||||||
|
if chunk.Offset+int64Size > int64(size) {
|
||||||
|
// this chunk is truncated
|
||||||
|
int64Size = int64(size) - chunk.Offset
|
||||||
|
if int64Size > 0 {
|
||||||
|
chunks = append(chunks, chunk)
|
||||||
|
glog.V(4).Infof("truncated chunk %+v from %d to %d\n", chunk.GetFileIdString(), chunk.Size, int64Size)
|
||||||
|
chunk.Size = uint64(int64Size)
|
||||||
|
} else {
|
||||||
|
glog.V(4).Infof("truncated whole chunk %+v\n", chunk.GetFileIdString())
|
||||||
|
truncatedChunks = append(truncatedChunks, chunk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// set the new chunks and reset entry cache
|
||||||
|
entry.Chunks = chunks
|
||||||
|
if fh != nil {
|
||||||
|
fh.entryViewCache = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry.Attributes.Mtime = time.Now().Unix()
|
||||||
|
entry.Attributes.FileSize = size
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if mode, ok := input.GetMode(); ok {
|
||||||
|
entry.Attributes.FileMode = uint32(mode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if uid, ok := input.GetUID(); ok {
|
||||||
|
entry.Attributes.Uid = uid
|
||||||
|
}
|
||||||
|
|
||||||
|
if gid, ok := input.GetGID(); ok {
|
||||||
|
entry.Attributes.Gid = gid
|
||||||
|
}
|
||||||
|
|
||||||
|
if mtime, ok := input.GetMTime(); ok {
|
||||||
|
entry.Attributes.Mtime = mtime.Unix()
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.Attributes.Mtime = time.Now().Unix()
|
||||||
|
out.AttrValid = 1
|
||||||
|
wfs.setAttrByPbEntry(&out.Attr, input.NodeId, entry)
|
||||||
|
|
||||||
|
if fh != nil {
|
||||||
|
fh.dirtyMetadata = true
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
return wfs.saveEntry(path, entry)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) setRootAttr(out *fuse.AttrOut) {
|
||||||
|
now := uint64(time.Now().Unix())
|
||||||
|
out.AttrValid = 119
|
||||||
|
out.Ino = 1
|
||||||
|
setBlksize(&out.Attr, blockSize)
|
||||||
|
out.Uid = wfs.option.MountUid
|
||||||
|
out.Gid = wfs.option.MountGid
|
||||||
|
out.Mtime = now
|
||||||
|
out.Ctime = now
|
||||||
|
out.Atime = now
|
||||||
|
out.Mode = toSystemType(os.ModeDir) | uint32(wfs.option.MountMode)
|
||||||
|
out.Nlink = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) setAttrByPbEntry(out *fuse.Attr, inode uint64, entry *filer_pb.Entry) {
|
||||||
|
out.Ino = inode
|
||||||
|
out.Size = filer.FileSize(entry)
|
||||||
|
out.Blocks = (out.Size + blockSize - 1) / blockSize
|
||||||
|
setBlksize(out, blockSize)
|
||||||
|
out.Mtime = uint64(entry.Attributes.Mtime)
|
||||||
|
out.Ctime = uint64(entry.Attributes.Mtime)
|
||||||
|
out.Atime = uint64(entry.Attributes.Mtime)
|
||||||
|
out.Mode = toSystemMode(os.FileMode(entry.Attributes.FileMode))
|
||||||
|
if entry.HardLinkCounter > 0 {
|
||||||
|
out.Nlink = uint32(entry.HardLinkCounter)
|
||||||
|
} else {
|
||||||
|
out.Nlink = 1
|
||||||
|
}
|
||||||
|
out.Uid = entry.Attributes.Uid
|
||||||
|
out.Gid = entry.Attributes.Gid
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) setAttrByFilerEntry(out *fuse.Attr, inode uint64, entry *filer.Entry) {
|
||||||
|
out.Ino = inode
|
||||||
|
out.Size = entry.FileSize
|
||||||
|
out.Blocks = (out.Size + blockSize - 1) / blockSize
|
||||||
|
setBlksize(out, blockSize)
|
||||||
|
out.Atime = uint64(entry.Attr.Mtime.Unix())
|
||||||
|
out.Mtime = uint64(entry.Attr.Mtime.Unix())
|
||||||
|
out.Ctime = uint64(entry.Attr.Mtime.Unix())
|
||||||
|
out.Crtime_ = uint64(entry.Attr.Crtime.Unix())
|
||||||
|
out.Mode = toSystemMode(entry.Attr.Mode)
|
||||||
|
if entry.HardLinkCounter > 0 {
|
||||||
|
out.Nlink = uint32(entry.HardLinkCounter)
|
||||||
|
} else {
|
||||||
|
out.Nlink = 1
|
||||||
|
}
|
||||||
|
out.Uid = entry.Attr.Uid
|
||||||
|
out.Gid = entry.Attr.Gid
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) outputPbEntry(out *fuse.EntryOut, inode uint64, entry *filer_pb.Entry) {
|
||||||
|
out.NodeId = inode
|
||||||
|
out.Generation = 1
|
||||||
|
out.EntryValid = 1
|
||||||
|
out.AttrValid = 1
|
||||||
|
wfs.setAttrByPbEntry(&out.Attr, inode, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) outputFilerEntry(out *fuse.EntryOut, inode uint64, entry *filer.Entry) {
|
||||||
|
out.NodeId = inode
|
||||||
|
out.Generation = 1
|
||||||
|
out.EntryValid = 1
|
||||||
|
out.AttrValid = 1
|
||||||
|
wfs.setAttrByFilerEntry(&out.Attr, inode, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func toSystemMode(mode os.FileMode) uint32 {
|
||||||
|
return toSystemType(mode) | uint32(mode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func toSystemType(mode os.FileMode) uint32 {
|
||||||
|
switch mode & os.ModeType {
|
||||||
|
case os.ModeDir:
|
||||||
|
return syscall.S_IFDIR
|
||||||
|
case os.ModeSymlink:
|
||||||
|
return syscall.S_IFLNK
|
||||||
|
case os.ModeNamedPipe:
|
||||||
|
return syscall.S_IFIFO
|
||||||
|
case os.ModeSocket:
|
||||||
|
return syscall.S_IFSOCK
|
||||||
|
case os.ModeDevice:
|
||||||
|
return syscall.S_IFBLK
|
||||||
|
case os.ModeCharDevice:
|
||||||
|
return syscall.S_IFCHR
|
||||||
|
default:
|
||||||
|
return syscall.S_IFREG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func toFileType(mode uint32) os.FileMode {
|
||||||
|
switch mode & (syscall.S_IFMT & 0xffff) {
|
||||||
|
case syscall.S_IFDIR:
|
||||||
|
return os.ModeDir
|
||||||
|
case syscall.S_IFLNK:
|
||||||
|
return os.ModeSymlink
|
||||||
|
case syscall.S_IFIFO:
|
||||||
|
return os.ModeNamedPipe
|
||||||
|
case syscall.S_IFSOCK:
|
||||||
|
return os.ModeSocket
|
||||||
|
case syscall.S_IFBLK:
|
||||||
|
return os.ModeDevice
|
||||||
|
case syscall.S_IFCHR:
|
||||||
|
return os.ModeCharDevice
|
||||||
|
default:
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func toFileMode(mode uint32) os.FileMode {
|
||||||
|
return toFileType(mode) | os.FileMode(mode&07777)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setBlksize(out *fuse.Attr, size uint32) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setBlksize(out *fuse.Attr, size uint32) {
|
||||||
|
out.Blksize = size
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/mount/meta_cache"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Lookup is called by the kernel when the VFS wants to know
|
||||||
|
// about a file inside a directory. Many lookup calls can
|
||||||
|
// occur in parallel, but only one call happens for each (dir,
|
||||||
|
// name) pair.
|
||||||
|
|
||||||
|
func (wfs *WFS) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name string, out *fuse.EntryOut) (code fuse.Status) {
|
||||||
|
|
||||||
|
if s := checkName(name); s != fuse.OK {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
dirPath := wfs.inodeToPath.GetPath(header.NodeId)
|
||||||
|
|
||||||
|
fullFilePath := dirPath.Child(name)
|
||||||
|
|
||||||
|
visitErr := meta_cache.EnsureVisited(wfs.metaCache, wfs, dirPath)
|
||||||
|
if visitErr != nil {
|
||||||
|
glog.Errorf("dir Lookup %s: %v", dirPath, visitErr)
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
localEntry, cacheErr := wfs.metaCache.FindEntry(context.Background(), fullFilePath)
|
||||||
|
if cacheErr == filer_pb.ErrNotFound {
|
||||||
|
return fuse.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
|
if localEntry == nil {
|
||||||
|
// glog.V(3).Infof("dir Lookup cache miss %s", fullFilePath)
|
||||||
|
entry, err := filer_pb.GetEntry(wfs, fullFilePath)
|
||||||
|
if err != nil {
|
||||||
|
glog.V(1).Infof("dir GetEntry %s: %v", fullFilePath, err)
|
||||||
|
return fuse.ENOENT
|
||||||
|
}
|
||||||
|
localEntry = filer.FromPbEntry(string(dirPath), entry)
|
||||||
|
} else {
|
||||||
|
glog.V(4).Infof("dir Lookup cache hit %s", fullFilePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
if localEntry == nil {
|
||||||
|
return fuse.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
|
inode := wfs.inodeToPath.Lookup(fullFilePath, localEntry.IsDirectory())
|
||||||
|
|
||||||
|
wfs.outputFilerEntry(out, inode, localEntry)
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
/** Create a directory
|
||||||
|
*
|
||||||
|
* Note that the mode argument may not have the type specification
|
||||||
|
* bits set, i.e. S_ISDIR(mode) can be false. To obtain the
|
||||||
|
* correct directory type bits use mode|S_IFDIR
|
||||||
|
* */
|
||||||
|
func (wfs *WFS) Mkdir(cancel <-chan struct{}, in *fuse.MkdirIn, name string, out *fuse.EntryOut) (code fuse.Status) {
|
||||||
|
|
||||||
|
if s := checkName(name); s != fuse.OK {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
newEntry := &filer_pb.Entry{
|
||||||
|
Name: name,
|
||||||
|
IsDirectory: true,
|
||||||
|
Attributes: &filer_pb.FuseAttributes{
|
||||||
|
Mtime: time.Now().Unix(),
|
||||||
|
Crtime: time.Now().Unix(),
|
||||||
|
FileMode: uint32(os.ModeDir) | in.Mode&^uint32(wfs.option.Umask),
|
||||||
|
Uid: in.Uid,
|
||||||
|
Gid: in.Gid,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
dirFullPath := wfs.inodeToPath.GetPath(in.NodeId)
|
||||||
|
|
||||||
|
entryFullPath := dirFullPath.Child(name)
|
||||||
|
|
||||||
|
err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
|
wfs.mapPbIdFromLocalToFiler(newEntry)
|
||||||
|
defer wfs.mapPbIdFromFilerToLocal(newEntry)
|
||||||
|
|
||||||
|
request := &filer_pb.CreateEntryRequest{
|
||||||
|
Directory: string(dirFullPath),
|
||||||
|
Entry: newEntry,
|
||||||
|
Signatures: []int32{wfs.signature},
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(1).Infof("mkdir: %v", request)
|
||||||
|
if err := filer_pb.CreateEntry(client, request); err != nil {
|
||||||
|
glog.V(0).Infof("mkdir %s: %v", entryFullPath, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := wfs.metaCache.InsertEntry(context.Background(), filer.FromPbEntry(request.Directory, request.Entry)); err != nil {
|
||||||
|
return fmt.Errorf("local mkdir dir %s: %v", entryFullPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
glog.V(0).Infof("mkdir %s: %v", entryFullPath, err)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
|
inode := wfs.inodeToPath.Lookup(entryFullPath, true)
|
||||||
|
|
||||||
|
wfs.outputPbEntry(out, inode, newEntry)
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Remove a directory */
|
||||||
|
func (wfs *WFS) Rmdir(cancel <-chan struct{}, header *fuse.InHeader, name string) (code fuse.Status) {
|
||||||
|
|
||||||
|
if name == "." {
|
||||||
|
return fuse.Status(syscall.EINVAL)
|
||||||
|
}
|
||||||
|
if name == ".." {
|
||||||
|
return fuse.Status(syscall.ENOTEMPTY)
|
||||||
|
}
|
||||||
|
|
||||||
|
dirFullPath := wfs.inodeToPath.GetPath(header.NodeId)
|
||||||
|
entryFullPath := dirFullPath.Child(name)
|
||||||
|
|
||||||
|
glog.V(3).Infof("remove directory: %v", entryFullPath)
|
||||||
|
ignoreRecursiveErr := true // ignore recursion error since the OS should manage it
|
||||||
|
err := filer_pb.Remove(wfs, string(dirFullPath), name, true, true, ignoreRecursiveErr, false, []int32{wfs.signature})
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("remove %s: %v", entryFullPath, err)
|
||||||
|
if strings.Contains(err.Error(), filer.MsgFailDelNonEmptyFolder) {
|
||||||
|
return fuse.Status(syscall.ENOTEMPTY)
|
||||||
|
}
|
||||||
|
return fuse.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
|
wfs.metaCache.DeleteEntry(context.Background(), entryFullPath)
|
||||||
|
wfs.inodeToPath.RemovePath(entryFullPath)
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/mount/meta_cache"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"math"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Directory handling
|
||||||
|
|
||||||
|
/** Open directory
|
||||||
|
*
|
||||||
|
* Unless the 'default_permissions' mount option is given,
|
||||||
|
* this method should check if opendir is permitted for this
|
||||||
|
* directory. Optionally opendir may also return an arbitrary
|
||||||
|
* filehandle in the fuse_file_info structure, which will be
|
||||||
|
* passed to readdir, releasedir and fsyncdir.
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) OpenDir(cancel <-chan struct{}, input *fuse.OpenIn, out *fuse.OpenOut) (code fuse.Status) {
|
||||||
|
if !wfs.inodeToPath.HasInode(input.NodeId) {
|
||||||
|
return fuse.ENOENT
|
||||||
|
}
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Release directory
|
||||||
|
*
|
||||||
|
* If the directory has been removed after the call to opendir, the
|
||||||
|
* path parameter will be NULL.
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) ReleaseDir(input *fuse.ReleaseIn) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Synchronize directory contents
|
||||||
|
*
|
||||||
|
* If the directory has been removed after the call to opendir, the
|
||||||
|
* path parameter will be NULL.
|
||||||
|
*
|
||||||
|
* If the datasync parameter is non-zero, then only the user data
|
||||||
|
* should be flushed, not the meta data
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) FsyncDir(cancel <-chan struct{}, input *fuse.FsyncIn) (code fuse.Status) {
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Read directory
|
||||||
|
*
|
||||||
|
* The filesystem may choose between two modes of operation:
|
||||||
|
*
|
||||||
|
* 1) The readdir implementation ignores the offset parameter, and
|
||||||
|
* passes zero to the filler function's offset. The filler
|
||||||
|
* function will not return '1' (unless an error happens), so the
|
||||||
|
* whole directory is read in a single readdir operation.
|
||||||
|
*
|
||||||
|
* 2) The readdir implementation keeps track of the offsets of the
|
||||||
|
* directory entries. It uses the offset parameter and always
|
||||||
|
* passes non-zero offset to the filler function. When the buffer
|
||||||
|
* is full (or an error happens) the filler function will return
|
||||||
|
* '1'.
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) ReadDir(cancel <-chan struct{}, input *fuse.ReadIn, out *fuse.DirEntryList) (code fuse.Status) {
|
||||||
|
return wfs.doReadDirectory(input, out, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, out *fuse.DirEntryList) (code fuse.Status) {
|
||||||
|
return wfs.doReadDirectory(input, out, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPlusMode bool) fuse.Status {
|
||||||
|
dirPath := wfs.inodeToPath.GetPath(input.NodeId)
|
||||||
|
|
||||||
|
var counter uint64
|
||||||
|
var dirEntry fuse.DirEntry
|
||||||
|
if input.Offset == 0 {
|
||||||
|
counter++
|
||||||
|
dirEntry.Ino = input.NodeId
|
||||||
|
dirEntry.Name = "."
|
||||||
|
dirEntry.Mode = toSystemMode(os.ModeDir)
|
||||||
|
out.AddDirEntry(dirEntry)
|
||||||
|
|
||||||
|
counter++
|
||||||
|
parentDir, _ := dirPath.DirAndName()
|
||||||
|
parentInode := wfs.inodeToPath.GetInode(util.FullPath(parentDir))
|
||||||
|
dirEntry.Ino = parentInode
|
||||||
|
dirEntry.Name = ".."
|
||||||
|
dirEntry.Mode = toSystemMode(os.ModeDir)
|
||||||
|
out.AddDirEntry(dirEntry)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
processEachEntryFn := func(entry *filer.Entry, isLast bool) bool {
|
||||||
|
counter++
|
||||||
|
if counter <= input.Offset {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
dirEntry.Name = entry.Name()
|
||||||
|
inode := wfs.inodeToPath.GetInode(dirPath.Child(dirEntry.Name))
|
||||||
|
dirEntry.Ino = inode
|
||||||
|
dirEntry.Mode = toSystemMode(entry.Mode)
|
||||||
|
if !isPlusMode {
|
||||||
|
if !out.AddDirEntry(dirEntry) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entryOut := out.AddDirLookupEntry(dirEntry)
|
||||||
|
if entryOut == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
wfs.outputFilerEntry(entryOut, inode, entry)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := meta_cache.EnsureVisited(wfs.metaCache, wfs, dirPath); err != nil {
|
||||||
|
glog.Errorf("dir ReadDirAll %s: %v", dirPath, err)
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
listErr := wfs.metaCache.ListDirectoryEntries(context.Background(), dirPath, "", false, int64(math.MaxInt32), func(entry *filer.Entry) bool {
|
||||||
|
return processEachEntryFn(entry, false)
|
||||||
|
})
|
||||||
|
if listErr != nil {
|
||||||
|
glog.Errorf("list meta cache: %v", listErr)
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a file
|
||||||
|
*
|
||||||
|
* Open flags are available in fi->flags. The following rules
|
||||||
|
* apply.
|
||||||
|
*
|
||||||
|
* - Creation (O_CREAT, O_EXCL, O_NOCTTY) flags will be
|
||||||
|
* filtered out / handled by the kernel.
|
||||||
|
*
|
||||||
|
* - Access modes (O_RDONLY, O_WRONLY, O_RDWR) should be used
|
||||||
|
* by the filesystem to check if the operation is
|
||||||
|
* permitted. If the ``-o default_permissions`` mount
|
||||||
|
* option is given, this check is already done by the
|
||||||
|
* kernel before calling open() and may thus be omitted by
|
||||||
|
* the filesystem.
|
||||||
|
*
|
||||||
|
* - When writeback caching is enabled, the kernel may send
|
||||||
|
* read requests even for files opened with O_WRONLY. The
|
||||||
|
* filesystem should be prepared to handle this.
|
||||||
|
*
|
||||||
|
* - When writeback caching is disabled, the filesystem is
|
||||||
|
* expected to properly handle the O_APPEND flag and ensure
|
||||||
|
* that each write is appending to the end of the file.
|
||||||
|
*
|
||||||
|
* - When writeback caching is enabled, the kernel will
|
||||||
|
* handle O_APPEND. However, unless all changes to the file
|
||||||
|
* come through the kernel this will not work reliably. The
|
||||||
|
* filesystem should thus either ignore the O_APPEND flag
|
||||||
|
* (and let the kernel handle it), or return an error
|
||||||
|
* (indicating that reliably O_APPEND is not available).
|
||||||
|
*
|
||||||
|
* Filesystem may store an arbitrary file handle (pointer,
|
||||||
|
* index, etc) in fi->fh, and use this in other all other file
|
||||||
|
* operations (read, write, flush, release, fsync).
|
||||||
|
*
|
||||||
|
* Filesystem may also implement stateless file I/O and not store
|
||||||
|
* anything in fi->fh.
|
||||||
|
*
|
||||||
|
* There are also some flags (direct_io, keep_cache) which the
|
||||||
|
* filesystem may set in fi, to change the way the file is opened.
|
||||||
|
* See fuse_file_info structure in <fuse_common.h> for more details.
|
||||||
|
*
|
||||||
|
* If this request is answered with an error code of ENOSYS
|
||||||
|
* and FUSE_CAP_NO_OPEN_SUPPORT is set in
|
||||||
|
* `fuse_conn_info.capable`, this is treated as success and
|
||||||
|
* future calls to open and release will also succeed without being
|
||||||
|
* sent to the filesystem process.
|
||||||
|
*
|
||||||
|
* Valid replies:
|
||||||
|
* fuse_reply_open
|
||||||
|
* fuse_reply_err
|
||||||
|
*
|
||||||
|
* @param req request handle
|
||||||
|
* @param ino the inode number
|
||||||
|
* @param fi file information
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Open(cancel <-chan struct{}, in *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) {
|
||||||
|
fileHandle, code := wfs.AcquireHandle(in.NodeId, in.Uid, in.Gid)
|
||||||
|
if code == fuse.OK {
|
||||||
|
out.Fh = uint64(fileHandle.fh)
|
||||||
|
}
|
||||||
|
return code
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release an open file
|
||||||
|
*
|
||||||
|
* Release is called when there are no more references to an open
|
||||||
|
* file: all file descriptors are closed and all memory mappings
|
||||||
|
* are unmapped.
|
||||||
|
*
|
||||||
|
* For every open call there will be exactly one release call (unless
|
||||||
|
* the filesystem is force-unmounted).
|
||||||
|
*
|
||||||
|
* The filesystem may reply with an error, but error values are
|
||||||
|
* not returned to close() or munmap() which triggered the
|
||||||
|
* release.
|
||||||
|
*
|
||||||
|
* fi->fh will contain the value set by the open method, or will
|
||||||
|
* be undefined if the open method didn't set any value.
|
||||||
|
* fi->flags will contain the same flags as for open.
|
||||||
|
*
|
||||||
|
* Valid replies:
|
||||||
|
* fuse_reply_err
|
||||||
|
*
|
||||||
|
* @param req request handle
|
||||||
|
* @param ino the inode number
|
||||||
|
* @param fi file information
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Release(cancel <-chan struct{}, in *fuse.ReleaseIn) {
|
||||||
|
wfs.ReleaseHandle(FileHandleId(in.Fh))
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and open a file
|
||||||
|
*
|
||||||
|
* If the file does not exist, first create it with the specified
|
||||||
|
* mode, and then open it.
|
||||||
|
*
|
||||||
|
* If this method is not implemented or under Linux kernel
|
||||||
|
* versions earlier than 2.6.15, the mknod() and open() methods
|
||||||
|
* will be called instead.
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Create(cancel <-chan struct{}, in *fuse.CreateIn, name string, out *fuse.CreateOut) (code fuse.Status) {
|
||||||
|
// if implemented, need to use
|
||||||
|
// inode := wfs.inodeToPath.Lookup(entryFullPath)
|
||||||
|
// to ensure nlookup counter
|
||||||
|
return fuse.ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create a file node
|
||||||
|
*
|
||||||
|
* This is called for creation of all non-directory, non-symlink
|
||||||
|
* nodes. If the filesystem defines a create() method, then for
|
||||||
|
* regular files that will be called instead.
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out *fuse.EntryOut) (code fuse.Status) {
|
||||||
|
|
||||||
|
if s := checkName(name); s != fuse.OK {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
newEntry := &filer_pb.Entry{
|
||||||
|
Name: name,
|
||||||
|
IsDirectory: false,
|
||||||
|
Attributes: &filer_pb.FuseAttributes{
|
||||||
|
Mtime: time.Now().Unix(),
|
||||||
|
Crtime: time.Now().Unix(),
|
||||||
|
FileMode: uint32(toFileMode(in.Mode) &^ wfs.option.Umask),
|
||||||
|
Uid: in.Uid,
|
||||||
|
Gid: in.Gid,
|
||||||
|
Collection: wfs.option.Collection,
|
||||||
|
Replication: wfs.option.Replication,
|
||||||
|
TtlSec: wfs.option.TtlSec,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
dirFullPath := wfs.inodeToPath.GetPath(in.NodeId)
|
||||||
|
|
||||||
|
entryFullPath := dirFullPath.Child(name)
|
||||||
|
|
||||||
|
err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
|
wfs.mapPbIdFromLocalToFiler(newEntry)
|
||||||
|
defer wfs.mapPbIdFromFilerToLocal(newEntry)
|
||||||
|
|
||||||
|
request := &filer_pb.CreateEntryRequest{
|
||||||
|
Directory: string(dirFullPath),
|
||||||
|
Entry: newEntry,
|
||||||
|
Signatures: []int32{wfs.signature},
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(1).Infof("mknod: %v", request)
|
||||||
|
if err := filer_pb.CreateEntry(client, request); err != nil {
|
||||||
|
glog.V(0).Infof("mknod %s: %v", entryFullPath, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := wfs.metaCache.InsertEntry(context.Background(), filer.FromPbEntry(request.Directory, request.Entry)); err != nil {
|
||||||
|
return fmt.Errorf("local mknod %s: %v", entryFullPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
glog.V(0).Infof("mknod %s: %v", entryFullPath, err)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
|
inode := wfs.inodeToPath.Lookup(entryFullPath, false)
|
||||||
|
|
||||||
|
wfs.outputPbEntry(out, inode, newEntry)
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Remove a file */
|
||||||
|
func (wfs *WFS) Unlink(cancel <-chan struct{}, header *fuse.InHeader, name string) (code fuse.Status) {
|
||||||
|
|
||||||
|
dirFullPath := wfs.inodeToPath.GetPath(header.NodeId)
|
||||||
|
entryFullPath := dirFullPath.Child(name)
|
||||||
|
|
||||||
|
entry, status := wfs.maybeLoadEntry(entryFullPath)
|
||||||
|
if status != fuse.OK {
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
|
||||||
|
// first, ensure the filer store can correctly delete
|
||||||
|
glog.V(3).Infof("remove file: %v", entryFullPath)
|
||||||
|
isDeleteData := entry != nil && entry.HardLinkCounter <= 1
|
||||||
|
err := filer_pb.Remove(wfs, string(dirFullPath), name, isDeleteData, false, false, false, []int32{wfs.signature})
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("remove %s: %v", entryFullPath, err)
|
||||||
|
return fuse.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
|
// then, delete meta cache
|
||||||
|
if err = wfs.metaCache.DeleteEntry(context.Background(), entryFullPath); err != nil {
|
||||||
|
glog.V(3).Infof("local DeleteEntry %s: %v", entryFullPath, err)
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
|
wfs.metaCache.DeleteEntry(context.Background(), entryFullPath)
|
||||||
|
wfs.inodeToPath.RemovePath(entryFullPath)
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read data
|
||||||
|
*
|
||||||
|
* Read should send exactly the number of bytes requested except
|
||||||
|
* on EOF or error, otherwise the rest of the data will be
|
||||||
|
* substituted with zeroes. An exception to this is when the file
|
||||||
|
* has been opened in 'direct_io' mode, in which case the return
|
||||||
|
* value of the read system call will reflect the return value of
|
||||||
|
* this operation.
|
||||||
|
*
|
||||||
|
* fi->fh will contain the value set by the open method, or will
|
||||||
|
* be undefined if the open method didn't set any value.
|
||||||
|
*
|
||||||
|
* Valid replies:
|
||||||
|
* fuse_reply_buf
|
||||||
|
* fuse_reply_iov
|
||||||
|
* fuse_reply_data
|
||||||
|
* fuse_reply_err
|
||||||
|
*
|
||||||
|
* @param req request handle
|
||||||
|
* @param ino the inode number
|
||||||
|
* @param size number of bytes to read
|
||||||
|
* @param off offset to read from
|
||||||
|
* @param fi file information
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Read(cancel <-chan struct{}, in *fuse.ReadIn, buff []byte) (fuse.ReadResult, fuse.Status) {
|
||||||
|
fh := wfs.GetHandle(FileHandleId(in.Fh))
|
||||||
|
if fh == nil {
|
||||||
|
return nil, fuse.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
|
offset := int64(in.Offset)
|
||||||
|
fh.lockForRead(offset, len(buff))
|
||||||
|
defer fh.unlockForRead(offset, len(buff))
|
||||||
|
|
||||||
|
totalRead, err := fh.readFromChunks(buff, offset)
|
||||||
|
if err == nil || err == io.EOF {
|
||||||
|
maxStop := fh.readFromDirtyPages(buff, offset)
|
||||||
|
totalRead = max(maxStop-offset, totalRead)
|
||||||
|
}
|
||||||
|
if err == io.EOF {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
glog.Warningf("file handle read %s %d: %v", fh.FullPath(), totalRead, err)
|
||||||
|
return nil, fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
|
return fuse.ReadResultData(buff[:totalRead]), fuse.OK
|
||||||
|
}
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush method
|
||||||
|
*
|
||||||
|
* This is called on each close() of the opened file.
|
||||||
|
*
|
||||||
|
* Since file descriptors can be duplicated (dup, dup2, fork), for
|
||||||
|
* one open call there may be many flush calls.
|
||||||
|
*
|
||||||
|
* Filesystems shouldn't assume that flush will always be called
|
||||||
|
* after some writes, or that if will be called at all.
|
||||||
|
*
|
||||||
|
* fi->fh will contain the value set by the open method, or will
|
||||||
|
* be undefined if the open method didn't set any value.
|
||||||
|
*
|
||||||
|
* NOTE: the name of the method is misleading, since (unlike
|
||||||
|
* fsync) the filesystem is not forced to flush pending writes.
|
||||||
|
* One reason to flush data is if the filesystem wants to return
|
||||||
|
* write errors during close. However, such use is non-portable
|
||||||
|
* because POSIX does not require [close] to wait for delayed I/O to
|
||||||
|
* complete.
|
||||||
|
*
|
||||||
|
* If the filesystem supports file locking operations (setlk,
|
||||||
|
* getlk) it should remove all locks belonging to 'fi->owner'.
|
||||||
|
*
|
||||||
|
* If this request is answered with an error code of ENOSYS,
|
||||||
|
* this is treated as success and future calls to flush() will
|
||||||
|
* succeed automatically without being send to the filesystem
|
||||||
|
* process.
|
||||||
|
*
|
||||||
|
* Valid replies:
|
||||||
|
* fuse_reply_err
|
||||||
|
*
|
||||||
|
* @param req request handle
|
||||||
|
* @param ino the inode number
|
||||||
|
* @param fi file information
|
||||||
|
*
|
||||||
|
* [close]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Flush(cancel <-chan struct{}, in *fuse.FlushIn) fuse.Status {
|
||||||
|
fh := wfs.GetHandle(FileHandleId(in.Fh))
|
||||||
|
if fh == nil {
|
||||||
|
return fuse.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
|
fh.Lock()
|
||||||
|
defer fh.Unlock()
|
||||||
|
|
||||||
|
return wfs.doFlush(fh, in.Uid, in.Gid)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronize file contents
|
||||||
|
*
|
||||||
|
* If the datasync parameter is non-zero, then only the user data
|
||||||
|
* should be flushed, not the meta data.
|
||||||
|
*
|
||||||
|
* If this request is answered with an error code of ENOSYS,
|
||||||
|
* this is treated as success and future calls to fsync() will
|
||||||
|
* succeed automatically without being send to the filesystem
|
||||||
|
* process.
|
||||||
|
*
|
||||||
|
* Valid replies:
|
||||||
|
* fuse_reply_err
|
||||||
|
*
|
||||||
|
* @param req request handle
|
||||||
|
* @param ino the inode number
|
||||||
|
* @param datasync flag indicating if only data should be flushed
|
||||||
|
* @param fi file information
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Fsync(cancel <-chan struct{}, in *fuse.FsyncIn) (code fuse.Status) {
|
||||||
|
|
||||||
|
fh := wfs.GetHandle(FileHandleId(in.Fh))
|
||||||
|
if fh == nil {
|
||||||
|
return fuse.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
|
fh.Lock()
|
||||||
|
defer fh.Unlock()
|
||||||
|
|
||||||
|
return wfs.doFlush(fh, in.Uid, in.Gid)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status {
|
||||||
|
// flush works at fh level
|
||||||
|
fileFullPath := fh.FullPath()
|
||||||
|
dir, _ := fileFullPath.DirAndName()
|
||||||
|
// send the data to the OS
|
||||||
|
glog.V(4).Infof("doFlush %s fh %d", fileFullPath, fh.handle)
|
||||||
|
|
||||||
|
if err := fh.dirtyPages.FlushData(); err != nil {
|
||||||
|
glog.Errorf("%v doFlush: %v", fileFullPath, err)
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
|
if !fh.dirtyMetadata {
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
|
entry := fh.entry
|
||||||
|
if entry == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if entry.Attributes != nil {
|
||||||
|
entry.Attributes.Mime = fh.contentType
|
||||||
|
if entry.Attributes.Uid == 0 {
|
||||||
|
entry.Attributes.Uid = uid
|
||||||
|
}
|
||||||
|
if entry.Attributes.Gid == 0 {
|
||||||
|
entry.Attributes.Gid = gid
|
||||||
|
}
|
||||||
|
if entry.Attributes.Crtime == 0 {
|
||||||
|
entry.Attributes.Crtime = time.Now().Unix()
|
||||||
|
}
|
||||||
|
entry.Attributes.Mtime = time.Now().Unix()
|
||||||
|
entry.Attributes.FileMode = uint32(os.FileMode(entry.Attributes.FileMode) &^ wfs.option.Umask)
|
||||||
|
entry.Attributes.Collection, entry.Attributes.Replication = fh.dirtyPages.GetStorageOptions()
|
||||||
|
}
|
||||||
|
|
||||||
|
request := &filer_pb.CreateEntryRequest{
|
||||||
|
Directory: string(dir),
|
||||||
|
Entry: entry,
|
||||||
|
Signatures: []int32{wfs.signature},
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(4).Infof("%s set chunks: %v", fileFullPath, len(entry.Chunks))
|
||||||
|
for i, chunk := range entry.Chunks {
|
||||||
|
glog.V(4).Infof("%s chunks %d: %v [%d,%d)", fileFullPath, i, chunk.GetFileIdString(), chunk.Offset, chunk.Offset+int64(chunk.Size))
|
||||||
|
}
|
||||||
|
|
||||||
|
manifestChunks, nonManifestChunks := filer.SeparateManifestChunks(entry.Chunks)
|
||||||
|
|
||||||
|
chunks, _ := filer.CompactFileChunks(wfs.LookupFn(), nonManifestChunks)
|
||||||
|
chunks, manifestErr := filer.MaybeManifestize(wfs.saveDataAsChunk(fileFullPath), chunks)
|
||||||
|
if manifestErr != nil {
|
||||||
|
// not good, but should be ok
|
||||||
|
glog.V(0).Infof("MaybeManifestize: %v", manifestErr)
|
||||||
|
}
|
||||||
|
entry.Chunks = append(chunks, manifestChunks...)
|
||||||
|
|
||||||
|
wfs.mapPbIdFromLocalToFiler(request.Entry)
|
||||||
|
defer wfs.mapPbIdFromFilerToLocal(request.Entry)
|
||||||
|
|
||||||
|
if err := filer_pb.CreateEntry(client, request); err != nil {
|
||||||
|
glog.Errorf("fh flush create %s: %v", fileFullPath, err)
|
||||||
|
return fmt.Errorf("fh flush create %s: %v", fileFullPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
wfs.metaCache.InsertEntry(context.Background(), filer.FromPbEntry(request.Directory, request.Entry))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
fh.dirtyMetadata = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("%v fh %d flush: %v", fileFullPath, fh.handle, err)
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write data
|
||||||
|
*
|
||||||
|
* Write should return exactly the number of bytes requested
|
||||||
|
* except on error. An exception to this is when the file has
|
||||||
|
* been opened in 'direct_io' mode, in which case the return value
|
||||||
|
* of the write system call will reflect the return value of this
|
||||||
|
* operation.
|
||||||
|
*
|
||||||
|
* Unless FUSE_CAP_HANDLE_KILLPRIV is disabled, this method is
|
||||||
|
* expected to reset the setuid and setgid bits.
|
||||||
|
*
|
||||||
|
* fi->fh will contain the value set by the open method, or will
|
||||||
|
* be undefined if the open method didn't set any value.
|
||||||
|
*
|
||||||
|
* Valid replies:
|
||||||
|
* fuse_reply_write
|
||||||
|
* fuse_reply_err
|
||||||
|
*
|
||||||
|
* @param req request handle
|
||||||
|
* @param ino the inode number
|
||||||
|
* @param buf data to write
|
||||||
|
* @param size number of bytes to write
|
||||||
|
* @param off offset to write to
|
||||||
|
* @param fi file information
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Write(cancel <-chan struct{}, in *fuse.WriteIn, data []byte) (written uint32, code fuse.Status) {
|
||||||
|
|
||||||
|
fh := wfs.GetHandle(FileHandleId(in.Fh))
|
||||||
|
if fh == nil {
|
||||||
|
return 0, fuse.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
|
fh.Lock()
|
||||||
|
defer fh.Unlock()
|
||||||
|
|
||||||
|
entry := fh.entry
|
||||||
|
if entry == nil {
|
||||||
|
return 0, fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.Content = nil
|
||||||
|
offset := int64(in.Offset)
|
||||||
|
entry.Attributes.FileSize = uint64(max(offset+int64(len(data)), int64(entry.Attributes.FileSize)))
|
||||||
|
// glog.V(4).Infof("%v write [%d,%d) %d", fh.f.fullpath(), req.Offset, req.Offset+int64(len(req.Data)), len(req.Data))
|
||||||
|
|
||||||
|
fh.dirtyPages.AddPage(offset, data)
|
||||||
|
|
||||||
|
written = uint32(len(data))
|
||||||
|
|
||||||
|
if offset == 0 {
|
||||||
|
// detect mime type
|
||||||
|
fh.contentType = http.DetectContentType(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fh.dirtyMetadata = true
|
||||||
|
|
||||||
|
return written, fuse.OK
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import "github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
|
||||||
|
func (wfs *WFS) AcquireHandle(inode uint64, uid, gid uint32) (fileHandle *FileHandle, code fuse.Status) {
|
||||||
|
_, _, entry, status := wfs.maybeReadEntry(inode)
|
||||||
|
if status == fuse.OK {
|
||||||
|
fileHandle = wfs.fhmap.AcquireFileHandle(wfs, inode, entry)
|
||||||
|
fileHandle.entry = entry
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) ReleaseHandle(handleId FileHandleId) {
|
||||||
|
wfs.fhmap.ReleaseByHandle(handleId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) GetHandle(handleId FileHandleId) *FileHandle {
|
||||||
|
return wfs.fhmap.GetFileHandle(handleId)
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Forget is called when the kernel discards entries from its
|
||||||
|
// dentry cache. This happens on unmount, and when the kernel
|
||||||
|
// is short on memory. Since it is not guaranteed to occur at
|
||||||
|
// any moment, and since there is no return value, Forget
|
||||||
|
// should not do I/O, as there is no channel to report back
|
||||||
|
// I/O errors.
|
||||||
|
// from https://github.com/libfuse/libfuse/blob/master/include/fuse_lowlevel.h
|
||||||
|
/**
|
||||||
|
* Forget about an inode
|
||||||
|
*
|
||||||
|
* This function is called when the kernel removes an inode
|
||||||
|
* from its internal caches.
|
||||||
|
*
|
||||||
|
* The inode's lookup count increases by one for every call to
|
||||||
|
* fuse_reply_entry and fuse_reply_create. The nlookup parameter
|
||||||
|
* indicates by how much the lookup count should be decreased.
|
||||||
|
*
|
||||||
|
* Inodes with a non-zero lookup count may receive request from
|
||||||
|
* the kernel even after calls to unlink, rmdir or (when
|
||||||
|
* overwriting an existing file) rename. Filesystems must handle
|
||||||
|
* such requests properly and it is recommended to defer removal
|
||||||
|
* of the inode until the lookup count reaches zero. Calls to
|
||||||
|
* unlink, rmdir or rename will be followed closely by forget
|
||||||
|
* unless the file or directory is open, in which case the
|
||||||
|
* kernel issues forget only after the release or releasedir
|
||||||
|
* calls.
|
||||||
|
*
|
||||||
|
* Note that if a file system will be exported over NFS the
|
||||||
|
* inodes lifetime must extend even beyond forget. See the
|
||||||
|
* generation field in struct fuse_entry_param above.
|
||||||
|
*
|
||||||
|
* On unmount the lookup count for all inodes implicitly drops
|
||||||
|
* to zero. It is not guaranteed that the file system will
|
||||||
|
* receive corresponding forget messages for the affected
|
||||||
|
* inodes.
|
||||||
|
*
|
||||||
|
* Valid replies:
|
||||||
|
* fuse_reply_none
|
||||||
|
*
|
||||||
|
* @param req request handle
|
||||||
|
* @param ino the inode number
|
||||||
|
* @param nlookup the number of lookups to forget
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
https://libfuse.github.io/doxygen/include_2fuse__lowlevel_8h.html
|
||||||
|
|
||||||
|
int fuse_reply_entry ( fuse_req_t req,
|
||||||
|
const struct fuse_entry_param * e
|
||||||
|
)
|
||||||
|
Reply with a directory entry
|
||||||
|
|
||||||
|
Possible requests: lookup, mknod, mkdir, symlink, link
|
||||||
|
|
||||||
|
Side effects: increments the lookup count on success
|
||||||
|
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Forget(nodeid, nlookup uint64) {
|
||||||
|
wfs.inodeToPath.Forget(nodeid, nlookup, func(dir util.FullPath) {
|
||||||
|
wfs.metaCache.DeleteFolderChildren(context.Background(), dir)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HARD_LINK_MARKER = '\x01'
|
||||||
|
)
|
||||||
|
|
||||||
|
/** Create a hard link to a file */
|
||||||
|
func (wfs *WFS) Link(cancel <-chan struct{}, in *fuse.LinkIn, name string, out *fuse.EntryOut) (code fuse.Status) {
|
||||||
|
|
||||||
|
if s := checkName(name); s != fuse.OK {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
newParentPath := wfs.inodeToPath.GetPath(in.NodeId)
|
||||||
|
oldEntryPath := wfs.inodeToPath.GetPath(in.Oldnodeid)
|
||||||
|
oldParentPath, _ := oldEntryPath.DirAndName()
|
||||||
|
|
||||||
|
oldEntry, status := wfs.maybeLoadEntry(oldEntryPath)
|
||||||
|
if status != fuse.OK {
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
|
||||||
|
// update old file to hardlink mode
|
||||||
|
if len(oldEntry.HardLinkId) == 0 {
|
||||||
|
oldEntry.HardLinkId = append(util.RandomBytes(16), HARD_LINK_MARKER)
|
||||||
|
oldEntry.HardLinkCounter = 1
|
||||||
|
}
|
||||||
|
oldEntry.HardLinkCounter++
|
||||||
|
updateOldEntryRequest := &filer_pb.UpdateEntryRequest{
|
||||||
|
Directory: oldParentPath,
|
||||||
|
Entry: oldEntry,
|
||||||
|
Signatures: []int32{wfs.signature},
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateLink 1.2 : update new file to hardlink mode
|
||||||
|
oldEntry.Attributes.Mtime = time.Now().Unix()
|
||||||
|
request := &filer_pb.CreateEntryRequest{
|
||||||
|
Directory: string(newParentPath),
|
||||||
|
Entry: &filer_pb.Entry{
|
||||||
|
Name: name,
|
||||||
|
IsDirectory: false,
|
||||||
|
Attributes: oldEntry.Attributes,
|
||||||
|
Chunks: oldEntry.Chunks,
|
||||||
|
Extended: oldEntry.Extended,
|
||||||
|
HardLinkId: oldEntry.HardLinkId,
|
||||||
|
HardLinkCounter: oldEntry.HardLinkCounter,
|
||||||
|
},
|
||||||
|
Signatures: []int32{wfs.signature},
|
||||||
|
}
|
||||||
|
|
||||||
|
// apply changes to the filer, and also apply to local metaCache
|
||||||
|
err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
|
wfs.mapPbIdFromLocalToFiler(request.Entry)
|
||||||
|
defer wfs.mapPbIdFromFilerToLocal(request.Entry)
|
||||||
|
|
||||||
|
if err := filer_pb.UpdateEntry(client, updateOldEntryRequest); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
wfs.metaCache.UpdateEntry(context.Background(), filer.FromPbEntry(updateOldEntryRequest.Directory, updateOldEntryRequest.Entry))
|
||||||
|
|
||||||
|
if err := filer_pb.CreateEntry(client, request); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
wfs.metaCache.InsertEntry(context.Background(), filer.FromPbEntry(request.Directory, request.Entry))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
newEntryPath := newParentPath.Child(name)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("Link %v -> %s: %v", oldEntryPath, newEntryPath, err)
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
|
inode := wfs.inodeToPath.Lookup(newEntryPath, false)
|
||||||
|
|
||||||
|
wfs.outputPbEntry(out, inode, request.Entry)
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fs"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"io"
|
||||||
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
/** Rename a file
|
||||||
|
*
|
||||||
|
* If the target exists it should be atomically replaced. If
|
||||||
|
* the target's inode's lookup count is non-zero, the file
|
||||||
|
* system is expected to postpone any removal of the inode
|
||||||
|
* until the lookup count reaches zero (see description of the
|
||||||
|
* forget function).
|
||||||
|
*
|
||||||
|
* If this request is answered with an error code of ENOSYS, this is
|
||||||
|
* treated as a permanent failure with error code EINVAL, i.e. all
|
||||||
|
* future bmap requests will fail with EINVAL without being
|
||||||
|
* send to the filesystem process.
|
||||||
|
*
|
||||||
|
* *flags* may be `RENAME_EXCHANGE` or `RENAME_NOREPLACE`. If
|
||||||
|
* RENAME_NOREPLACE is specified, the filesystem must not
|
||||||
|
* overwrite *newname* if it exists and return an error
|
||||||
|
* instead. If `RENAME_EXCHANGE` is specified, the filesystem
|
||||||
|
* must atomically exchange the two files, i.e. both must
|
||||||
|
* exist and neither may be deleted.
|
||||||
|
*
|
||||||
|
* Valid replies:
|
||||||
|
* fuse_reply_err
|
||||||
|
*
|
||||||
|
* @param req request handle
|
||||||
|
* @param parent inode number of the old parent directory
|
||||||
|
* @param name old name
|
||||||
|
* @param newparent inode number of the new parent directory
|
||||||
|
* @param newname new name
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
renameat2()
|
||||||
|
renameat2() has an additional flags argument. A renameat2() call
|
||||||
|
with a zero flags argument is equivalent to renameat().
|
||||||
|
|
||||||
|
The flags argument is a bit mask consisting of zero or more of
|
||||||
|
the following flags:
|
||||||
|
|
||||||
|
RENAME_EXCHANGE
|
||||||
|
Atomically exchange oldpath and newpath. Both pathnames
|
||||||
|
must exist but may be of different types (e.g., one could
|
||||||
|
be a non-empty directory and the other a symbolic link).
|
||||||
|
|
||||||
|
RENAME_NOREPLACE
|
||||||
|
Don't overwrite newpath of the rename. Return an error if
|
||||||
|
newpath already exists.
|
||||||
|
|
||||||
|
RENAME_NOREPLACE can't be employed together with
|
||||||
|
RENAME_EXCHANGE.
|
||||||
|
|
||||||
|
RENAME_NOREPLACE requires support from the underlying
|
||||||
|
filesystem. Support for various filesystems was added as
|
||||||
|
follows:
|
||||||
|
|
||||||
|
* ext4 (Linux 3.15);
|
||||||
|
|
||||||
|
* btrfs, tmpfs, and cifs (Linux 3.17);
|
||||||
|
|
||||||
|
* xfs (Linux 4.0);
|
||||||
|
|
||||||
|
* Support for many other filesystems was added in Linux
|
||||||
|
4.9, including ext2, minix, reiserfs, jfs, vfat, and
|
||||||
|
bpf.
|
||||||
|
|
||||||
|
RENAME_WHITEOUT (since Linux 3.18)
|
||||||
|
This operation makes sense only for overlay/union
|
||||||
|
filesystem implementations.
|
||||||
|
|
||||||
|
Specifying RENAME_WHITEOUT creates a "whiteout" object at
|
||||||
|
the source of the rename at the same time as performing
|
||||||
|
the rename. The whole operation is atomic, so that if the
|
||||||
|
rename succeeds then the whiteout will also have been
|
||||||
|
created.
|
||||||
|
|
||||||
|
A "whiteout" is an object that has special meaning in
|
||||||
|
union/overlay filesystem constructs. In these constructs,
|
||||||
|
multiple layers exist and only the top one is ever
|
||||||
|
modified. A whiteout on an upper layer will effectively
|
||||||
|
hide a matching file in the lower layer, making it appear
|
||||||
|
as if the file didn't exist.
|
||||||
|
|
||||||
|
When a file that exists on the lower layer is renamed, the
|
||||||
|
file is first copied up (if not already on the upper
|
||||||
|
layer) and then renamed on the upper, read-write layer.
|
||||||
|
At the same time, the source file needs to be "whiteouted"
|
||||||
|
(so that the version of the source file in the lower layer
|
||||||
|
is rendered invisible). The whole operation needs to be
|
||||||
|
done atomically.
|
||||||
|
|
||||||
|
When not part of a union/overlay, the whiteout appears as
|
||||||
|
a character device with a {0,0} device number. (Note that
|
||||||
|
other union/overlay implementations may employ different
|
||||||
|
methods for storing whiteout entries; specifically, BSD
|
||||||
|
union mount employs a separate inode type, DT_WHT, which,
|
||||||
|
while supported by some filesystems available in Linux,
|
||||||
|
such as CODA and XFS, is ignored by the kernel's whiteout
|
||||||
|
support code, as of Linux 4.19, at least.)
|
||||||
|
|
||||||
|
RENAME_WHITEOUT requires the same privileges as creating a
|
||||||
|
device node (i.e., the CAP_MKNOD capability).
|
||||||
|
|
||||||
|
RENAME_WHITEOUT can't be employed together with
|
||||||
|
RENAME_EXCHANGE.
|
||||||
|
|
||||||
|
RENAME_WHITEOUT requires support from the underlying
|
||||||
|
filesystem. Among the filesystems that support it are
|
||||||
|
tmpfs (since Linux 3.18), ext4 (since Linux 3.18), XFS
|
||||||
|
(since Linux 4.1), f2fs (since Linux 4.2), btrfs (since
|
||||||
|
Linux 4.7), and ubifs (since Linux 4.9).
|
||||||
|
*/
|
||||||
|
const (
|
||||||
|
RenameEmptyFlag = 0
|
||||||
|
RenameNoReplace = 1
|
||||||
|
RenameExchange = fs.RENAME_EXCHANGE
|
||||||
|
RenameWhiteout = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
func (wfs *WFS) Rename(cancel <-chan struct{}, in *fuse.RenameIn, oldName string, newName string) (code fuse.Status) {
|
||||||
|
if s := checkName(newName); s != fuse.OK {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
switch in.Flags {
|
||||||
|
case RenameEmptyFlag:
|
||||||
|
case RenameNoReplace:
|
||||||
|
case RenameExchange:
|
||||||
|
case RenameWhiteout:
|
||||||
|
return fuse.ENOTSUP
|
||||||
|
default:
|
||||||
|
return fuse.EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
oldDir := wfs.inodeToPath.GetPath(in.NodeId)
|
||||||
|
oldPath := oldDir.Child(oldName)
|
||||||
|
newDir := wfs.inodeToPath.GetPath(in.Newdir)
|
||||||
|
newPath := newDir.Child(newName)
|
||||||
|
|
||||||
|
glog.V(4).Infof("dir Rename %s => %s", oldPath, newPath)
|
||||||
|
|
||||||
|
// update remote filer
|
||||||
|
err := wfs.WithFilerClient(true, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
request := &filer_pb.StreamRenameEntryRequest{
|
||||||
|
OldDirectory: string(oldDir),
|
||||||
|
OldName: oldName,
|
||||||
|
NewDirectory: string(newDir),
|
||||||
|
NewName: newName,
|
||||||
|
Signatures: []int32{wfs.signature},
|
||||||
|
}
|
||||||
|
|
||||||
|
stream, err := client.StreamRenameEntry(ctx, request)
|
||||||
|
if err != nil {
|
||||||
|
code = fuse.EIO
|
||||||
|
return fmt.Errorf("dir AtomicRenameEntry %s => %s : %v", oldPath, newPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
resp, recvErr := stream.Recv()
|
||||||
|
if recvErr != nil {
|
||||||
|
if recvErr == io.EOF {
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
if strings.Contains(recvErr.Error(), "not empty") {
|
||||||
|
code = fuse.Status(syscall.ENOTEMPTY)
|
||||||
|
} else if strings.Contains(recvErr.Error(), "not directory") {
|
||||||
|
code = fuse.ENOTDIR
|
||||||
|
}
|
||||||
|
return fmt.Errorf("dir Rename %s => %s receive: %v", oldPath, newPath, recvErr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = wfs.handleRenameResponse(ctx, resp); err != nil {
|
||||||
|
glog.V(0).Infof("dir Rename %s => %s : %v", oldPath, newPath, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("Link: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamRenameEntryResponse) error {
|
||||||
|
// comes from filer StreamRenameEntry, can only be create or delete entry
|
||||||
|
|
||||||
|
if resp.EventNotification.NewEntry != nil {
|
||||||
|
// with new entry, the old entry name also exists. This is the first step to create new entry
|
||||||
|
newEntry := filer.FromPbEntry(resp.EventNotification.NewParentPath, resp.EventNotification.NewEntry)
|
||||||
|
if err := wfs.metaCache.AtomicUpdateEntryFromFiler(ctx, "", newEntry); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
oldParent, newParent := util.FullPath(resp.Directory), util.FullPath(resp.EventNotification.NewParentPath)
|
||||||
|
oldName, newName := resp.EventNotification.OldEntry.Name, resp.EventNotification.NewEntry.Name
|
||||||
|
|
||||||
|
oldPath := oldParent.Child(oldName)
|
||||||
|
newPath := newParent.Child(newName)
|
||||||
|
|
||||||
|
wfs.inodeToPath.MovePath(oldPath, newPath)
|
||||||
|
|
||||||
|
} else if resp.EventNotification.OldEntry != nil {
|
||||||
|
// without new entry, only old entry name exists. This is the second step to delete old entry
|
||||||
|
if err := wfs.metaCache.AtomicUpdateEntryFromFiler(ctx, util.NewFullPath(resp.Directory, resp.EventNotification.OldEntry.Name), nil); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"math"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const blockSize = 512
|
||||||
|
|
||||||
|
type statsCache struct {
|
||||||
|
filer_pb.StatisticsResponse
|
||||||
|
lastChecked int64 // unix time in seconds
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) StatFs(cancel <-chan struct{}, in *fuse.InHeader, out *fuse.StatfsOut) (code fuse.Status) {
|
||||||
|
|
||||||
|
glog.V(4).Infof("reading fs stats")
|
||||||
|
|
||||||
|
if wfs.stats.lastChecked < time.Now().Unix()-20 {
|
||||||
|
|
||||||
|
err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
|
request := &filer_pb.StatisticsRequest{
|
||||||
|
Collection: wfs.option.Collection,
|
||||||
|
Replication: wfs.option.Replication,
|
||||||
|
Ttl: fmt.Sprintf("%ds", wfs.option.TtlSec),
|
||||||
|
DiskType: string(wfs.option.DiskType),
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(4).Infof("reading filer stats: %+v", request)
|
||||||
|
resp, err := client.Statistics(context.Background(), request)
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("reading filer stats %v: %v", request, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
glog.V(4).Infof("read filer stats: %+v", resp)
|
||||||
|
|
||||||
|
wfs.stats.TotalSize = resp.TotalSize
|
||||||
|
wfs.stats.UsedSize = resp.UsedSize
|
||||||
|
wfs.stats.FileCount = resp.FileCount
|
||||||
|
wfs.stats.lastChecked = time.Now().Unix()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("filer Statistics: %v", err)
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
totalDiskSize := wfs.stats.TotalSize
|
||||||
|
usedDiskSize := wfs.stats.UsedSize
|
||||||
|
actualFileCount := wfs.stats.FileCount
|
||||||
|
|
||||||
|
// Compute the total number of available blocks
|
||||||
|
out.Blocks = totalDiskSize / blockSize
|
||||||
|
|
||||||
|
// Compute the number of used blocks
|
||||||
|
numBlocks := uint64(usedDiskSize / blockSize)
|
||||||
|
|
||||||
|
// Report the number of free and available blocks for the block size
|
||||||
|
out.Bfree = out.Blocks - numBlocks
|
||||||
|
out.Bavail = out.Blocks - numBlocks
|
||||||
|
out.Bsize = uint32(blockSize)
|
||||||
|
|
||||||
|
// Report the total number of possible files in the file system (and those free)
|
||||||
|
out.Files = math.MaxInt64
|
||||||
|
out.Ffree = math.MaxInt64 - actualFileCount
|
||||||
|
|
||||||
|
// Report the maximum length of a name and the minimum fragment size
|
||||||
|
out.NameLen = 1024
|
||||||
|
out.Frsize = uint32(blockSize)
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
/** Create a symbolic link */
|
||||||
|
func (wfs *WFS) Symlink(cancel <-chan struct{}, header *fuse.InHeader, target string, name string, out *fuse.EntryOut) (code fuse.Status) {
|
||||||
|
|
||||||
|
if s := checkName(name); s != fuse.OK {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
dirPath := wfs.inodeToPath.GetPath(header.NodeId)
|
||||||
|
entryFullPath := dirPath.Child(name)
|
||||||
|
|
||||||
|
request := &filer_pb.CreateEntryRequest{
|
||||||
|
Directory: string(dirPath),
|
||||||
|
Entry: &filer_pb.Entry{
|
||||||
|
Name: name,
|
||||||
|
IsDirectory: false,
|
||||||
|
Attributes: &filer_pb.FuseAttributes{
|
||||||
|
Mtime: time.Now().Unix(),
|
||||||
|
Crtime: time.Now().Unix(),
|
||||||
|
FileMode: uint32((os.FileMode(0777) | os.ModeSymlink) &^ wfs.option.Umask),
|
||||||
|
Uid: header.Uid,
|
||||||
|
Gid: header.Gid,
|
||||||
|
SymlinkTarget: target,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Signatures: []int32{wfs.signature},
|
||||||
|
}
|
||||||
|
|
||||||
|
err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
|
wfs.mapPbIdFromLocalToFiler(request.Entry)
|
||||||
|
defer wfs.mapPbIdFromFilerToLocal(request.Entry)
|
||||||
|
|
||||||
|
if err := filer_pb.CreateEntry(client, request); err != nil {
|
||||||
|
return fmt.Errorf("symlink %s: %v", entryFullPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
wfs.metaCache.InsertEntry(context.Background(), filer.FromPbEntry(request.Directory, request.Entry))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("Symlink %s => %s: %v", entryFullPath, target, err)
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
|
inode := wfs.inodeToPath.Lookup(entryFullPath, false)
|
||||||
|
|
||||||
|
wfs.outputPbEntry(out, inode, request.Entry)
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) Readlink(cancel <-chan struct{}, header *fuse.InHeader) (out []byte, code fuse.Status) {
|
||||||
|
entryFullPath := wfs.inodeToPath.GetPath(header.NodeId)
|
||||||
|
|
||||||
|
entry, status := wfs.maybeLoadEntry(entryFullPath)
|
||||||
|
if status != fuse.OK {
|
||||||
|
return nil, status
|
||||||
|
}
|
||||||
|
if os.FileMode(entry.Attributes.FileMode)&os.ModeSymlink == 0 {
|
||||||
|
return nil, fuse.EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
return []byte(entry.Attributes.SymlinkTarget), fuse.OK
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import "github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
|
||||||
|
// https://github.com/libfuse/libfuse/blob/48ae2e72b39b6a31cb2194f6f11786b7ca06aac6/include/fuse.h#L778
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy a range of data from one file to anotherNiels de Vos, 4 years ago: • libfuse: add copy_file_range() support
|
||||||
|
*
|
||||||
|
* Performs an optimized copy between two file descriptors without the
|
||||||
|
* additional cost of transferring data through the FUSE kernel module
|
||||||
|
* to user space (glibc) and then back into the FUSE filesystem again.
|
||||||
|
*
|
||||||
|
* In case this method is not implemented, applications are expected to
|
||||||
|
* fall back to a regular file copy. (Some glibc versions did this
|
||||||
|
* emulation automatically, but the emulation has been removed from all
|
||||||
|
* glibc release branches.)
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) CopyFileRange(cancel <-chan struct{}, in *fuse.CopyFileRangeIn) (written uint32, code fuse.Status) {
|
||||||
|
return 0, fuse.ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocates space for an open file
|
||||||
|
*
|
||||||
|
* This function ensures that required space is allocated for specified
|
||||||
|
* file. If this function returns success then any subsequent write
|
||||||
|
* request to specified range is guaranteed not to fail because of lack
|
||||||
|
* of space on the file system media.
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Fallocate(cancel <-chan struct{}, in *fuse.FallocateIn) (code fuse.Status) {
|
||||||
|
return fuse.ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find next data or hole after the specified offset
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Lseek(cancel <-chan struct{}, in *fuse.LseekIn, out *fuse.LseekOut) fuse.Status {
|
||||||
|
return fuse.ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) GetLk(cancel <-chan struct{}, in *fuse.LkIn, out *fuse.LkOut) (code fuse.Status) {
|
||||||
|
return fuse.ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) SetLk(cancel <-chan struct{}, in *fuse.LkIn) (code fuse.Status) {
|
||||||
|
return fuse.ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) SetLkw(cancel <-chan struct{}, in *fuse.LkIn) (code fuse.Status) {
|
||||||
|
return fuse.ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check file access permissions
|
||||||
|
*
|
||||||
|
* This will be called for the access() system call. If the
|
||||||
|
* 'default_permissions' mount option is given, this method is not
|
||||||
|
* called.
|
||||||
|
*
|
||||||
|
* This method is not called under Linux kernel versions 2.4.x
|
||||||
|
*/
|
||||||
|
func (wfs *WFS) Access(cancel <-chan struct{}, input *fuse.AccessIn) (code fuse.Status) {
|
||||||
|
return fuse.ENOSYS
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/operation"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/security"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (wfs *WFS) saveDataAsChunk(fullPath util.FullPath) filer.SaveDataAsChunkFunctionType {
|
||||||
|
|
||||||
|
return func(reader io.Reader, filename string, offset int64) (chunk *filer_pb.FileChunk, collection, replication string, err error) {
|
||||||
|
var fileId, host string
|
||||||
|
var auth security.EncodedJwt
|
||||||
|
|
||||||
|
if err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
return util.Retry("assignVolume", func() error {
|
||||||
|
request := &filer_pb.AssignVolumeRequest{
|
||||||
|
Count: 1,
|
||||||
|
Replication: wfs.option.Replication,
|
||||||
|
Collection: wfs.option.Collection,
|
||||||
|
TtlSec: wfs.option.TtlSec,
|
||||||
|
DiskType: string(wfs.option.DiskType),
|
||||||
|
DataCenter: wfs.option.DataCenter,
|
||||||
|
Path: string(fullPath),
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.AssignVolume(context.Background(), request)
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("assign volume failure %v: %v", request, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if resp.Error != "" {
|
||||||
|
return fmt.Errorf("assign volume failure %v: %v", request, resp.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fileId, auth = resp.FileId, security.EncodedJwt(resp.Auth)
|
||||||
|
loc := resp.Location
|
||||||
|
host = wfs.AdjustedUrl(loc)
|
||||||
|
collection, replication = resp.Collection, resp.Replication
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}); err != nil {
|
||||||
|
return nil, "", "", fmt.Errorf("filerGrpcAddress assign volume: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fileUrl := fmt.Sprintf("http://%s/%s", host, fileId)
|
||||||
|
if wfs.option.VolumeServerAccess == "filerProxy" {
|
||||||
|
fileUrl = fmt.Sprintf("http://%s/?proxyChunkId=%s", wfs.getCurrentFiler(), fileId)
|
||||||
|
}
|
||||||
|
uploadOption := &operation.UploadOption{
|
||||||
|
UploadUrl: fileUrl,
|
||||||
|
Filename: filename,
|
||||||
|
Cipher: wfs.option.Cipher,
|
||||||
|
IsInputCompressed: false,
|
||||||
|
MimeType: "",
|
||||||
|
PairMap: nil,
|
||||||
|
Jwt: auth,
|
||||||
|
}
|
||||||
|
uploadResult, err, data := operation.Upload(reader, uploadOption)
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("upload data %v to %s: %v", filename, fileUrl, err)
|
||||||
|
return nil, "", "", fmt.Errorf("upload data: %v", err)
|
||||||
|
}
|
||||||
|
if uploadResult.Error != "" {
|
||||||
|
glog.V(0).Infof("upload failure %v to %s: %v", filename, fileUrl, err)
|
||||||
|
return nil, "", "", fmt.Errorf("upload result: %v", uploadResult.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
if offset == 0 {
|
||||||
|
wfs.chunkCache.SetChunk(fileId, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
chunk = uploadResult.ToPbFileChunk(fileId, offset)
|
||||||
|
return chunk, collection, replication, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
sys "golang.org/x/sys/unix"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// https://man7.org/linux/man-pages/man7/xattr.7.html#:~:text=The%20VFS%20imposes%20limitations%20that,in%20listxattr(2)).
|
||||||
|
MAX_XATTR_NAME_SIZE = 255
|
||||||
|
MAX_XATTR_VALUE_SIZE = 65536
|
||||||
|
XATTR_PREFIX = "xattr-" // same as filer
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetXAttr reads an extended attribute, and should return the
|
||||||
|
// number of bytes. If the buffer is too small, return ERANGE,
|
||||||
|
// with the required buffer size.
|
||||||
|
func (wfs *WFS) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr string, dest []byte) (size uint32, code fuse.Status) {
|
||||||
|
|
||||||
|
//validate attr name
|
||||||
|
if len(attr) > MAX_XATTR_NAME_SIZE {
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
return 0, fuse.EPERM
|
||||||
|
} else {
|
||||||
|
return 0, fuse.ERANGE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(attr) == 0 {
|
||||||
|
return 0, fuse.EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, entry, status := wfs.maybeReadEntry(header.NodeId)
|
||||||
|
if status != fuse.OK {
|
||||||
|
return 0, status
|
||||||
|
}
|
||||||
|
if entry == nil {
|
||||||
|
return 0, fuse.ENOENT
|
||||||
|
}
|
||||||
|
if entry.Extended == nil {
|
||||||
|
return 0, fuse.ENOATTR
|
||||||
|
}
|
||||||
|
data, found := entry.Extended[XATTR_PREFIX+attr]
|
||||||
|
if !found {
|
||||||
|
return 0, fuse.ENOATTR
|
||||||
|
}
|
||||||
|
if len(dest) < len(data) {
|
||||||
|
return uint32(len(data)), fuse.ERANGE
|
||||||
|
}
|
||||||
|
copy(dest, data)
|
||||||
|
|
||||||
|
return uint32(len(data)), fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetXAttr writes an extended attribute.
|
||||||
|
// https://man7.org/linux/man-pages/man2/setxattr.2.html
|
||||||
|
// By default (i.e., flags is zero), the extended attribute will be
|
||||||
|
// created if it does not exist, or the value will be replaced if
|
||||||
|
// the attribute already exists. To modify these semantics, one of
|
||||||
|
// the following values can be specified in flags:
|
||||||
|
//
|
||||||
|
// XATTR_CREATE
|
||||||
|
// Perform a pure create, which fails if the named attribute
|
||||||
|
// exists already.
|
||||||
|
//
|
||||||
|
// XATTR_REPLACE
|
||||||
|
// Perform a pure replace operation, which fails if the named
|
||||||
|
// attribute does not already exist.
|
||||||
|
func (wfs *WFS) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, attr string, data []byte) fuse.Status {
|
||||||
|
//validate attr name
|
||||||
|
if len(attr) > MAX_XATTR_NAME_SIZE {
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
return fuse.EPERM
|
||||||
|
} else {
|
||||||
|
return fuse.ERANGE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(attr) == 0 {
|
||||||
|
return fuse.EINVAL
|
||||||
|
}
|
||||||
|
//validate attr value
|
||||||
|
if len(data) > MAX_XATTR_VALUE_SIZE {
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
return fuse.Status(syscall.E2BIG)
|
||||||
|
} else {
|
||||||
|
return fuse.ERANGE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
path, _, entry, status := wfs.maybeReadEntry(input.NodeId)
|
||||||
|
if status != fuse.OK {
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
if entry.Extended == nil {
|
||||||
|
entry.Extended = make(map[string][]byte)
|
||||||
|
}
|
||||||
|
oldData, _ := entry.Extended[XATTR_PREFIX+attr]
|
||||||
|
switch input.Flags {
|
||||||
|
case sys.XATTR_CREATE:
|
||||||
|
if len(oldData) > 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
fallthrough
|
||||||
|
case sys.XATTR_REPLACE:
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
entry.Extended[XATTR_PREFIX+attr] = data
|
||||||
|
}
|
||||||
|
|
||||||
|
return wfs.saveEntry(path, entry)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListXAttr lists extended attributes as '\0' delimited byte
|
||||||
|
// slice, and return the number of bytes. If the buffer is too
|
||||||
|
// small, return ERANGE, with the required buffer size.
|
||||||
|
func (wfs *WFS) ListXAttr(cancel <-chan struct{}, header *fuse.InHeader, dest []byte) (n uint32, code fuse.Status) {
|
||||||
|
_, _, entry, status := wfs.maybeReadEntry(header.NodeId)
|
||||||
|
if status != fuse.OK {
|
||||||
|
return 0, status
|
||||||
|
}
|
||||||
|
if entry == nil {
|
||||||
|
return 0, fuse.ENOENT
|
||||||
|
}
|
||||||
|
if entry.Extended == nil {
|
||||||
|
return 0, fuse.ENOATTR
|
||||||
|
}
|
||||||
|
|
||||||
|
var data []byte
|
||||||
|
for k := range entry.Extended {
|
||||||
|
if strings.HasPrefix(k, XATTR_PREFIX) {
|
||||||
|
data = append(data, k[len(XATTR_PREFIX):]...)
|
||||||
|
data = append(data, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(dest) < len(data) {
|
||||||
|
return uint32(len(data)), fuse.ERANGE
|
||||||
|
}
|
||||||
|
|
||||||
|
copy(dest, data)
|
||||||
|
|
||||||
|
return uint32(len(data)), fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveXAttr removes an extended attribute.
|
||||||
|
func (wfs *WFS) RemoveXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr string) fuse.Status {
|
||||||
|
if len(attr) == 0 {
|
||||||
|
return fuse.EINVAL
|
||||||
|
}
|
||||||
|
path, _, entry, status := wfs.maybeReadEntry(header.NodeId)
|
||||||
|
if status != fuse.OK {
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
if entry.Extended == nil {
|
||||||
|
return fuse.ENOATTR
|
||||||
|
}
|
||||||
|
_, found := entry.Extended[XATTR_PREFIX+attr]
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
return fuse.ENOATTR
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(entry.Extended, XATTR_PREFIX+attr)
|
||||||
|
|
||||||
|
return wfs.saveEntry(path, entry)
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = filer_pb.FilerClient(&WFS{})
|
||||||
|
|
||||||
|
func (wfs *WFS) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) (err error) {
|
||||||
|
|
||||||
|
return util.Retry("filer grpc", func() error {
|
||||||
|
|
||||||
|
i := wfs.option.filerIndex
|
||||||
|
n := len(wfs.option.FilerAddresses)
|
||||||
|
for x := 0; x < n; x++ {
|
||||||
|
|
||||||
|
filerGrpcAddress := wfs.option.FilerAddresses[i].ToGrpcAddress()
|
||||||
|
err = pb.WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
|
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||||
|
return fn(client)
|
||||||
|
}, filerGrpcAddress, wfs.option.GrpcDialOption)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
glog.V(0).Infof("WithFilerClient %d %v: %v", x, filerGrpcAddress, err)
|
||||||
|
} else {
|
||||||
|
wfs.option.filerIndex = i
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
i++
|
||||||
|
if i >= n {
|
||||||
|
i = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) AdjustedUrl(location *filer_pb.Location) string {
|
||||||
|
if wfs.option.VolumeServerAccess == "publicUrl" {
|
||||||
|
return location.PublicUrl
|
||||||
|
}
|
||||||
|
return location.Url
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package mount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (wfs *WFS) saveEntry(path util.FullPath, entry *filer_pb.Entry) (code fuse.Status) {
|
||||||
|
|
||||||
|
parentDir, _ := path.DirAndName()
|
||||||
|
|
||||||
|
err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
|
wfs.mapPbIdFromLocalToFiler(entry)
|
||||||
|
defer wfs.mapPbIdFromFilerToLocal(entry)
|
||||||
|
|
||||||
|
request := &filer_pb.UpdateEntryRequest{
|
||||||
|
Directory: parentDir,
|
||||||
|
Entry: entry,
|
||||||
|
Signatures: []int32{wfs.signature},
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(1).Infof("save entry: %v", request)
|
||||||
|
_, err := client.UpdateEntry(context.Background(), request)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("UpdateEntry dir %s: %v", path, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := wfs.metaCache.UpdateEntry(context.Background(), filer.FromPbEntry(request.Directory, request.Entry)); err != nil {
|
||||||
|
return fmt.Errorf("UpdateEntry dir %s: %v", path, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("saveEntry %s: %v", path, err)
|
||||||
|
return fuse.EIO
|
||||||
|
}
|
||||||
|
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) mapPbIdFromFilerToLocal(entry *filer_pb.Entry) {
|
||||||
|
if entry.Attributes == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
entry.Attributes.Uid, entry.Attributes.Gid = wfs.option.UidGidMapper.FilerToLocal(entry.Attributes.Uid, entry.Attributes.Gid)
|
||||||
|
}
|
||||||
|
func (wfs *WFS) mapPbIdFromLocalToFiler(entry *filer_pb.Entry) {
|
||||||
|
if entry.Attributes == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
entry.Attributes.Uid, entry.Attributes.Gid = wfs.option.UidGidMapper.LocalToFiler(entry.Attributes.Uid, entry.Attributes.Gid)
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkName(name string) fuse.Status {
|
||||||
|
if len(name) >= 256 {
|
||||||
|
return fuse.Status(syscall.ENAMETOOLONG)
|
||||||
|
}
|
||||||
|
return fuse.OK
|
||||||
|
}
|
||||||
@@ -114,6 +114,7 @@ message Entry {
|
|||||||
bytes content = 9; // if not empty, the file content
|
bytes content = 9; // if not empty, the file content
|
||||||
|
|
||||||
RemoteEntry remote_entry = 10;
|
RemoteEntry remote_entry = 10;
|
||||||
|
int64 quota = 11; // for bucket only. Positive/Negative means enabled/disabled.
|
||||||
}
|
}
|
||||||
|
|
||||||
message FullEntry {
|
message FullEntry {
|
||||||
|
|||||||
+515
-505
File diff suppressed because it is too large.
Load diff
@@ -45,9 +45,8 @@ func NewGrpcServer(opts ...grpc.ServerOption) *grpc.Server {
|
|||||||
var options []grpc.ServerOption
|
var options []grpc.ServerOption
|
||||||
options = append(options,
|
options = append(options,
|
||||||
grpc.KeepaliveParams(keepalive.ServerParameters{
|
grpc.KeepaliveParams(keepalive.ServerParameters{
|
||||||
Time: 10 * time.Second, // wait time before ping if no activity
|
Time: 10 * time.Second, // wait time before ping if no activity
|
||||||
Timeout: 20 * time.Second, // ping timeout
|
Timeout: 20 * time.Second, // ping timeout
|
||||||
MaxConnectionAge: 10 * time.Hour,
|
|
||||||
}),
|
}),
|
||||||
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
|
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
|
||||||
MinTime: 60 * time.Second, // min time a client should wait before sending a ping
|
MinTime: 60 * time.Second, // min time a client should wait before sending a ping
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ func (fs *FilerSink) UpdateEntry(key string, oldEntry *filer_pb.Entry, newParent
|
|||||||
// delete the chunks that are deleted from the source
|
// delete the chunks that are deleted from the source
|
||||||
if deleteIncludeChunks {
|
if deleteIncludeChunks {
|
||||||
// remove the deleted chunks. Actual data deletion happens in filer UpdateEntry FindUnusedFileChunks
|
// remove the deleted chunks. Actual data deletion happens in filer UpdateEntry FindUnusedFileChunks
|
||||||
existingEntry.Chunks = filer.DoMinusChunks(existingEntry.Chunks, deletedChunks)
|
existingEntry.Chunks = filer.DoMinusChunksBySourceFileId(existingEntry.Chunks, deletedChunks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// replicate the chunks that are new in the source
|
// replicate the chunks that are new in the source
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ func (progress *KafkaProgress) saveProgress() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to marshal progress: %v", err)
|
return fmt.Errorf("failed to marshal progress: %v", err)
|
||||||
}
|
}
|
||||||
err = os.WriteFile(progress.offsetFile, data, 0640)
|
err = util.WriteFile(progress.offsetFile, data, 0640)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to save progress to %s: %v", progress.offsetFile, err)
|
return fmt.Errorf("failed to save progress to %s: %v", progress.offsetFile, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chrislusf/seaweedfs/weed/filer"
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/s3api/s3_constants"
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/s3api/s3_constants"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
||||||
|
|
||||||
xhttp "github.com/chrislusf/seaweedfs/weed/s3api/http"
|
xhttp "github.com/chrislusf/seaweedfs/weed/s3api/http"
|
||||||
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
|
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
|
||||||
|
|
||||||
@@ -309,3 +310,15 @@ func (s3a *S3ApiServer) DeleteBucketLifecycleHandler(w http.ResponseWriter, r *h
|
|||||||
s3err.WriteEmptyResponse(w, r, http.StatusNoContent)
|
s3err.WriteEmptyResponse(w, r, http.StatusNoContent)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBucketLocationHandler Get bucket location
|
||||||
|
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLocation.html
|
||||||
|
func (s3a *S3ApiServer) GetBucketLocationHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
writeSuccessResponseXML(w, r, LocationConstraint{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBucketRequestPaymentHandler Get bucket location
|
||||||
|
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketRequestPayment.html
|
||||||
|
func (s3a *S3ApiServer) GetBucketRequestPaymentHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
writeSuccessResponseXML(w, r, RequestPaymentConfiguration{Payer: "BucketOwner"})
|
||||||
|
}
|
||||||
Loaded 100 of 148 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user