Skip to content

Commit 485dd75

Browse files
committed
Revert "libzfs: sendrecv: send_progress_thread: handle SIGINFO/SIGUSR1"
This reverts commit c2995a8.
1 parent b471ed4 commit 485dd75

File tree

3 files changed

+19
-96
lines changed

3 files changed

+19
-96
lines changed

lib/libzfs/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ libzfs_la_LIBADD = \
5858
libzutil.la \
5959
libuutil.la
6060

61-
libzfs_la_LIBADD += -lrt -lm $(LIBCRYPTO_LIBS) $(ZLIB_LIBS) $(LIBFETCH_LIBS) $(LTLIBINTL)
61+
libzfs_la_LIBADD += -lm $(LIBCRYPTO_LIBS) $(ZLIB_LIBS) $(LIBFETCH_LIBS) $(LTLIBINTL)
6262

6363
libzfs_la_LDFLAGS = -pthread
6464

lib/libzfs/libzfs_sendrecv.c

Lines changed: 17 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -928,39 +928,6 @@ zfs_send_progress(zfs_handle_t *zhp, int fd, uint64_t *bytes_written,
928928
return (0);
929929
}
930930

931-
static volatile boolean_t send_progress_thread_signal_duetotimer;
932-
static void
933-
send_progress_thread_act(int sig, siginfo_t *info, void *ucontext)
934-
{
935-
(void) sig, (void) ucontext;
936-
send_progress_thread_signal_duetotimer = info->si_code == SI_TIMER;
937-
}
938-
939-
struct timer_desirability {
940-
timer_t timer;
941-
boolean_t desired;
942-
};
943-
static void
944-
timer_delete_cleanup(void *timer)
945-
{
946-
struct timer_desirability *td = timer;
947-
if (td->desired)
948-
timer_delete(td->timer);
949-
}
950-
951-
#ifdef SIGINFO
952-
#define SEND_PROGRESS_THREAD_PARENT_BLOCK_SIGINFO sigaddset(&new, SIGINFO)
953-
#else
954-
#define SEND_PROGRESS_THREAD_PARENT_BLOCK_SIGINFO
955-
#endif
956-
#define SEND_PROGRESS_THREAD_PARENT_BLOCK(old) { \
957-
sigset_t new; \
958-
sigemptyset(&new); \
959-
sigaddset(&new, SIGUSR1); \
960-
SEND_PROGRESS_THREAD_PARENT_BLOCK_SIGINFO; \
961-
pthread_sigmask(SIG_BLOCK, &new, old); \
962-
}
963-
964931
static void *
965932
send_progress_thread(void *arg)
966933
{
@@ -974,26 +941,6 @@ send_progress_thread(void *arg)
974941
struct tm tm;
975942
int err;
976943

977-
const struct sigaction signal_action =
978-
{.sa_sigaction = send_progress_thread_act, .sa_flags = SA_SIGINFO};
979-
struct sigevent timer_cfg =
980-
{.sigev_notify = SIGEV_SIGNAL, .sigev_signo = SIGUSR1};
981-
const struct itimerspec timer_time =
982-
{.it_value = {.tv_sec = 1}, .it_interval = {.tv_sec = 1}};
983-
struct timer_desirability timer = {};
984-
985-
sigaction(SIGUSR1, &signal_action, NULL);
986-
#ifdef SIGINFO
987-
sigaction(SIGINFO, &signal_action, NULL);
988-
#endif
989-
990-
if ((timer.desired = pa->pa_progress || pa->pa_astitle)) {
991-
if (timer_create(CLOCK_MONOTONIC, &timer_cfg, &timer.timer))
992-
return ((void *)(uintptr_t)errno);
993-
(void) timer_settime(timer.timer, 0, &timer_time, NULL);
994-
}
995-
pthread_cleanup_push(timer_delete_cleanup, &timer);
996-
997944
if (!pa->pa_parsable && pa->pa_progress) {
998945
(void) fprintf(stderr,
999946
"TIME %s %sSNAPSHOT %s\n",
@@ -1006,12 +953,12 @@ send_progress_thread(void *arg)
1006953
* Print the progress from ZFS_IOC_SEND_PROGRESS every second.
1007954
*/
1008955
for (;;) {
1009-
pause();
956+
(void) sleep(1);
1010957
if ((err = zfs_send_progress(zhp, pa->pa_fd, &bytes,
1011958
&blocks)) != 0) {
1012959
if (err == EINTR || err == ENOENT)
1013-
err = 0;
1014-
pthread_exit(((void *)(uintptr_t)err));
960+
return ((void *)0);
961+
return ((void *)(uintptr_t)err);
1015962
}
1016963

1017964
(void) time(&t);
@@ -1044,26 +991,22 @@ send_progress_thread(void *arg)
1044991
(void) fprintf(stderr, "%02d:%02d:%02d\t%llu\t%s\n",
1045992
tm.tm_hour, tm.tm_min, tm.tm_sec,
1046993
(u_longlong_t)bytes, zhp->zfs_name);
1047-
} else if (pa->pa_progress ||
1048-
!send_progress_thread_signal_duetotimer) {
994+
} else if (pa->pa_progress) {
1049995
zfs_nicebytes(bytes, buf, sizeof (buf));
1050996
(void) fprintf(stderr, "%02d:%02d:%02d %5s %s\n",
1051997
tm.tm_hour, tm.tm_min, tm.tm_sec,
1052998
buf, zhp->zfs_name);
1053999
}
10541000
}
1055-
pthread_cleanup_pop(B_TRUE);
10561001
return (NULL);
10571002
}
10581003

10591004
static boolean_t
1060-
send_progress_thread_exit(
1061-
libzfs_handle_t *hdl, pthread_t ptid, sigset_t *oldmask)
1005+
send_progress_thread_exit(libzfs_handle_t *hdl, pthread_t ptid)
10621006
{
10631007
void *status = NULL;
10641008
(void) pthread_cancel(ptid);
10651009
(void) pthread_join(ptid, &status);
1066-
pthread_sigmask(SIG_SETMASK, oldmask, NULL);
10671010
int error = (int)(uintptr_t)status;
10681011
if (error != 0 && status != PTHREAD_CANCELED)
10691012
return (zfs_standard_error(hdl, error,
@@ -1257,8 +1200,7 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
12571200
* If progress reporting is requested, spawn a new thread to
12581201
* poll ZFS_IOC_SEND_PROGRESS at a regular interval.
12591202
*/
1260-
sigset_t oldmask;
1261-
{
1203+
if (sdd->progress || sdd->progressastitle) {
12621204
pa.pa_zhp = zhp;
12631205
pa.pa_fd = sdd->outfd;
12641206
pa.pa_parsable = sdd->parsable;
@@ -1273,13 +1215,13 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
12731215
zfs_close(zhp);
12741216
return (err);
12751217
}
1276-
SEND_PROGRESS_THREAD_PARENT_BLOCK(&oldmask);
12771218
}
12781219

12791220
err = dump_ioctl(zhp, sdd->prevsnap, sdd->prevsnap_obj,
12801221
fromorigin, sdd->outfd, flags, sdd->debugnv);
12811222

1282-
if (send_progress_thread_exit(zhp->zfs_hdl, tid, &oldmask))
1223+
if ((sdd->progress || sdd->progressastitle) &&
1224+
send_progress_thread_exit(zhp->zfs_hdl, tid))
12831225
return (-1);
12841226
}
12851227

@@ -1621,9 +1563,8 @@ estimate_size(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags,
16211563
progress_arg_t pa = { 0 };
16221564
int err = 0;
16231565
pthread_t ptid;
1624-
sigset_t oldmask;
16251566

1626-
{
1567+
if (flags->progress || flags->progressastitle) {
16271568
pa.pa_zhp = zhp;
16281569
pa.pa_fd = fd;
16291570
pa.pa_parsable = flags->parsable;
@@ -1637,15 +1578,15 @@ estimate_size(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags,
16371578
return (zfs_error(zhp->zfs_hdl,
16381579
EZFS_THREADCREATEFAILED, errbuf));
16391580
}
1640-
SEND_PROGRESS_THREAD_PARENT_BLOCK(&oldmask);
16411581
}
16421582

16431583
err = lzc_send_space_resume_redacted(zhp->zfs_name, from,
16441584
lzc_flags_from_sendflags(flags), resumeobj, resumeoff, bytes,
16451585
redactbook, fd, &size);
16461586
*sizep = size;
16471587

1648-
if (send_progress_thread_exit(zhp->zfs_hdl, ptid, &oldmask))
1588+
if ((flags->progress || flags->progressastitle) &&
1589+
send_progress_thread_exit(zhp->zfs_hdl, ptid))
16491590
return (-1);
16501591

16511592
if (!flags->progress && !flags->parsable)
@@ -1936,12 +1877,11 @@ zfs_send_resume_impl_cb_impl(libzfs_handle_t *hdl, sendflags_t *flags,
19361877
if (!flags->dryrun) {
19371878
progress_arg_t pa = { 0 };
19381879
pthread_t tid;
1939-
sigset_t oldmask;
19401880
/*
19411881
* If progress reporting is requested, spawn a new thread to
19421882
* poll ZFS_IOC_SEND_PROGRESS at a regular interval.
19431883
*/
1944-
{
1884+
if (flags->progress || flags->progressastitle) {
19451885
pa.pa_zhp = zhp;
19461886
pa.pa_fd = outfd;
19471887
pa.pa_parsable = flags->parsable;
@@ -1959,15 +1899,15 @@ zfs_send_resume_impl_cb_impl(libzfs_handle_t *hdl, sendflags_t *flags,
19591899
zfs_close(zhp);
19601900
return (error);
19611901
}
1962-
SEND_PROGRESS_THREAD_PARENT_BLOCK(&oldmask);
19631902
}
19641903

19651904
error = lzc_send_resume_redacted(zhp->zfs_name, fromname, outfd,
19661905
lzc_flags, resumeobj, resumeoff, redact_book);
19671906
if (redact_book != NULL)
19681907
free(redact_book);
19691908

1970-
if (send_progress_thread_exit(hdl, tid, &oldmask)) {
1909+
if ((flags->progressastitle || flags->progress) &&
1910+
send_progress_thread_exit(hdl, tid)) {
19711911
zfs_close(zhp);
19721912
return (-1);
19731913
}
@@ -2754,8 +2694,7 @@ zfs_send_one_cb_impl(zfs_handle_t *zhp, const char *from, int fd,
27542694
* If progress reporting is requested, spawn a new thread to poll
27552695
* ZFS_IOC_SEND_PROGRESS at a regular interval.
27562696
*/
2757-
sigset_t oldmask;
2758-
{
2697+
if (flags->progress || flags->progressastitle) {
27592698
pa.pa_zhp = zhp;
27602699
pa.pa_fd = fd;
27612700
pa.pa_parsable = flags->parsable;
@@ -2772,13 +2711,13 @@ zfs_send_one_cb_impl(zfs_handle_t *zhp, const char *from, int fd,
27722711
return (zfs_error(zhp->zfs_hdl,
27732712
EZFS_THREADCREATEFAILED, errbuf));
27742713
}
2775-
SEND_PROGRESS_THREAD_PARENT_BLOCK(&oldmask);
27762714
}
27772715

27782716
err = lzc_send_redacted(name, from, fd,
27792717
lzc_flags_from_sendflags(flags), redactbook);
27802718

2781-
if (send_progress_thread_exit(hdl, ptid, &oldmask))
2719+
if ((flags->progress || flags->progressastitle) &&
2720+
send_progress_thread_exit(hdl, ptid))
27822721
return (-1);
27832722

27842723
if (err == 0 && (flags->props || flags->holds || flags->backup)) {

man/man8/zfs-send.8

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
.\" Copyright 2018 Nexenta Systems, Inc.
3030
.\" Copyright 2019 Joyent, Inc.
3131
.\"
32-
.Dd July 27, 2023
32+
.Dd January 12, 2023
3333
.Dt ZFS-SEND 8
3434
.Os
3535
.
@@ -297,12 +297,6 @@ This flag can only be used in conjunction with
297297
.It Fl v , -verbose
298298
Print verbose information about the stream package generated.
299299
This information includes a per-second report of how much data has been sent.
300-
The same report can be requested by sending
301-
.Dv SIGINFO
302-
or
303-
.Dv SIGUSR1 ,
304-
regardless of
305-
.Fl v .
306300
.Pp
307301
The format of the stream is committed.
308302
You will be able to receive your streams on future versions of ZFS.
@@ -439,12 +433,6 @@ and the verbose output goes to standard error
439433
.It Fl v , -verbose
440434
Print verbose information about the stream package generated.
441435
This information includes a per-second report of how much data has been sent.
442-
The same report can be requested by sending
443-
.Dv SIGINFO
444-
or
445-
.Dv SIGUSR1 ,
446-
regardless of
447-
.Fl v .
448436
.El
449437
.It Xo
450438
.Nm zfs
@@ -681,10 +669,6 @@ ones on the source, and are ready to be used, while the parent snapshot on the
681669
target contains none of the username and password data present on the source,
682670
because it was removed by the redacted send operation.
683671
.
684-
.Sh SIGNALS
685-
See
686-
.Fl v .
687-
.
688672
.Sh EXAMPLES
689673
.\" These are, respectively, examples 12, 13 from zfs.8
690674
.\" Make sure to update them bidirectionally

0 commit comments

Comments
 (0)