2
* Copyright (C) 2005, 2006, 2007 Junjiro Okajima
4
* This program, aufs is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
/* $Id: dentry.c,v 1.40 2007/05/07 03:43:36 sfjro Exp $ */
21
//#include <linux/fs.h>
22
//#include <linux/namei.h>
25
#ifdef CONFIG_AUFS_LHASH_PATCH
27
#ifdef CONFIG_AUFS_DLGT
28
struct lookup_hash_args {
35
static void call_lookup_hash(void *args)
37
struct lookup_hash_args *a = args;
38
*a->errp = __lookup_hash(a->name, a->base, a->nd);
40
#endif /* CONFIG_AUFS_DLGT */
42
static struct dentry *lkup_hash(const char *name, struct dentry *parent,
43
int len, struct lkup_args *lkup)
45
struct dentry *dentry;
50
struct nameidata tmp_nd;
52
dentry = ERR_PTR(-EACCES);
59
hash = init_name_hash();
62
if (unlikely(c == '/' || c == '\0'))
64
hash = partial_name_hash(c, hash);
66
this.hash = end_name_hash(hash);
68
memset(&tmp_nd, 0, sizeof(tmp_nd));
69
tmp_nd.dentry = dget(parent);
70
tmp_nd.mnt = mntget(lkup->nfsmnt);
71
#ifndef CONFIG_AUFS_DLGT
72
dentry = __lookup_hash(&this, parent, &tmp_nd);
75
dentry = __lookup_hash(&this, parent, &tmp_nd);
77
struct lookup_hash_args args = {
83
au_wkq_wait(call_lookup_hash, &args, /*dlgt*/1);
86
path_release(&tmp_nd);
92
#elif defined(CONFIG_AUFS_DLGT)
93
static struct dentry *lkup_hash(const char *name, struct dentry *parent,
94
int len, struct lkup_args *lkup)
96
return ERR_PTR(-ENOSYS);
100
#ifdef CONFIG_AUFS_DLGT
101
struct lookup_one_len_args {
102
struct dentry **errp;
104
struct dentry *parent;
108
static void call_lookup_one_len(void *args)
110
struct lookup_one_len_args *a = args;
111
*a->errp = lookup_one_len(a->name, a->parent, a->len);
113
#endif /* CONFIG_AUFS_DLGT */
115
#if defined(CONFIG_AUFS_LHASH_PATCH) || defined(CONFIG_AUFS_DLGT)
116
/* cf. lookup_one_len() in linux/fs/namei.c */
117
struct dentry *lkup_one(const char *name, struct dentry *parent, int len,
118
struct lkup_args *lkup)
120
struct dentry *dentry;
122
LKTRTrace("%.*s/%.*s, lkup{%p, %d}\n",
123
DLNPair(parent), len, name, lkup->nfsmnt, lkup->dlgt);
126
#ifndef CONFIG_AUFS_DLGT
127
dentry = lookup_one_len(name, parent, len);
130
dentry = lookup_one_len(name, parent, len);
132
struct lookup_one_len_args args = {
138
au_wkq_wait(call_lookup_one_len, &args, /*dlgt*/1);
142
dentry = lkup_hash(name, parent, len, lkup);
149
struct lkup_one_args {
150
struct dentry **errp;
152
struct dentry *parent;
154
struct lkup_args *lkup;
157
static void call_lkup_one(void *args)
159
struct lkup_one_args *a = args;
160
*a->errp = lkup_one(a->name, a->parent, a->len, a->lkup);
164
* returns positive/negative dentry, NULL or an error.
165
* NULL means whiteout-ed or not-found.
167
static struct dentry *do_lookup(struct dentry *hidden_parent,
168
struct dentry *dentry, aufs_bindex_t bindex,
169
struct qstr *wh_name, int allow_neg,
170
mode_t type, int dlgt)
172
struct dentry *hidden_dentry;
173
int wh_found, wh_able, opq;
174
struct inode *hidden_dir, *hidden_inode;
176
struct super_block *sb;
177
struct lkup_args lkup = {.dlgt = dlgt};
179
LKTRTrace("%.*s/%.*s, b%d, allow_neg %d, type 0%o, dlgt %d\n",
180
DLNPair(hidden_parent), DLNPair(dentry), bindex, allow_neg,
182
DEBUG_ON(IS_ROOT(dentry));
183
hidden_dir = hidden_parent->d_inode;
184
IMustLock(hidden_dir);
188
wh_able = sbr_is_whable(sb, bindex);
189
lkup.nfsmnt = au_nfsmnt(sb, bindex);
190
name = &dentry->d_name;
191
if (unlikely(wh_able)) {
192
#if 0 //def CONFIG_AUFS_AS_BRANCH
193
if (strncmp(name->name, AUFS_WH_PFX, AUFS_WH_LEN))
194
wh_found = is_wh(hidden_parent, wh_name, /*try_sio*/0,
199
wh_found = is_wh(hidden_parent, wh_name, /*try_sio*/0, &lkup);
202
//if (LktrCond) wh_found = -1;
203
hidden_dentry = ERR_PTR(wh_found);
206
if (unlikely(wh_found < 0))
209
/* We found a whiteout */
210
//set_dbend(dentry, bindex);
211
set_dbwh(dentry, bindex);
213
return NULL; /* success */
217
hidden_dentry = lkup_one(name->name, hidden_parent, name->len, &lkup);
218
//if (LktrCond) {dput(hidden_dentry); hidden_dentry = ERR_PTR(-1);}
219
if (IS_ERR(hidden_dentry))
221
DEBUG_ON(d_unhashed(hidden_dentry));
222
hidden_inode = hidden_dentry->d_inode;
227
|| (type && type != (hidden_inode->i_mode & S_IFMT)))
230
if (dbend(dentry) <= bindex)
231
set_dbend(dentry, bindex);
232
if (dbstart(dentry) == -1 || bindex < dbstart(dentry))
233
set_dbstart(dentry, bindex);
234
set_h_dptr(dentry, bindex, hidden_dentry);
236
if (!hidden_inode || !S_ISDIR(hidden_inode->i_mode) || !wh_able)
237
return hidden_dentry; /* success */
239
hi_lock_child(hidden_inode);
240
opq = is_diropq(hidden_dentry, &lkup);
241
//if (LktrCond) opq = -1;
242
i_unlock(hidden_inode);
244
set_dbdiropq(dentry, bindex);
245
else if (unlikely(opq < 0)) {
246
set_h_dptr(dentry, bindex, NULL);
247
hidden_dentry = ERR_PTR(opq);
253
hidden_dentry = NULL;
255
TraceErrPtr(hidden_dentry);
256
return hidden_dentry;
260
* returns the number of hidden positive dentries,
261
* otherwise an error.
263
int lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type)
265
int npositive, err, allow_neg, dlgt;
266
struct dentry *parent;
267
aufs_bindex_t bindex, btail;
268
const struct qstr *name = &dentry->d_name;
270
struct super_block *sb;
272
LKTRTrace("%.*s, b%d, type 0%o\n", LNPair(name), bstart, type);
273
DEBUG_ON(bstart < 0 || IS_ROOT(dentry));
274
parent = dget_parent(dentry);
276
#if 1 //ndef CONFIG_AUFS_AS_BRANCH
278
if (unlikely(!strncmp(name->name, AUFS_WH_PFX, AUFS_WH_LEN)))
282
err = au_alloc_whname(name->name, name->len, &whname);
283
//if (LktrCond) {au_free_whname(&whname); err = -1;}
288
dlgt = need_dlgt(sb);
291
btail = dbtaildir(parent);
292
for (bindex = bstart; bindex <= btail; bindex++) {
293
struct dentry *hidden_parent, *hidden_dentry;
294
struct inode *hidden_inode;
295
struct inode *hidden_dir;
297
hidden_dentry = au_h_dptr_i(dentry, bindex);
299
if (hidden_dentry->d_inode)
305
hidden_parent = au_h_dptr_i(parent, bindex);
308
hidden_dir = hidden_parent->d_inode;
309
if (!hidden_dir || !S_ISDIR(hidden_dir->i_mode))
312
hi_lock_parent(hidden_dir);
313
hidden_dentry = do_lookup(hidden_parent, dentry, bindex,
314
&whname, allow_neg, type, dlgt);
315
// do not dput for testing
316
//if (LktrCond) {hidden_dentry = ERR_PTR(-1);}
317
i_unlock(hidden_dir);
318
err = PTR_ERR(hidden_dentry);
319
if (IS_ERR(hidden_dentry))
323
if (dbwh(dentry) != -1)
327
hidden_inode = hidden_dentry->d_inode;
332
type = hidden_inode->i_mode & S_IFMT;
335
else if (dbdiropq(dentry) != -1)
341
au_update_dbstart(dentry);
346
au_free_whname(&whname);
353
struct dentry *sio_lkup_one(const char *name, struct dentry *parent, int len,
354
struct lkup_args *lkup)
356
struct dentry *dentry;
358
LKTRTrace("%.*s/%.*s\n", DLNPair(parent), len, name);
359
IMustLock(parent->d_inode);
361
if (!au_test_perm(parent->d_inode, MAY_EXEC, lkup->dlgt))
362
dentry = lkup_one(name, parent, len, lkup);
365
int dlgt = lkup->dlgt;
366
struct lkup_one_args args = {
375
au_wkq_wait(call_lkup_one, &args, /*dlgt*/0);
384
* lookup @dentry on @bindex which should be negative.
386
int lkup_neg(struct dentry *dentry, aufs_bindex_t bindex)
389
struct dentry *parent, *hidden_parent, *hidden_dentry;
390
struct inode *hidden_dir;
391
struct lkup_args lkup;
393
LKTRTrace("%.*s, b%d\n", DLNPair(dentry), bindex);
394
parent = dget_parent(dentry);
395
DEBUG_ON(!parent || !parent->d_inode
396
|| !S_ISDIR(parent->d_inode->i_mode));
397
hidden_parent = au_h_dptr_i(parent, bindex);
398
DEBUG_ON(!hidden_parent);
399
hidden_dir = hidden_parent->d_inode;
400
DEBUG_ON(!hidden_dir || !S_ISDIR(hidden_dir->i_mode));
401
IMustLock(hidden_dir);
403
lkup.nfsmnt = au_nfsmnt(dentry->d_sb, bindex);
404
lkup.dlgt = need_dlgt(dentry->d_sb);
405
hidden_dentry = sio_lkup_one(dentry->d_name.name, hidden_parent,
406
dentry->d_name.len, &lkup);
407
//if (LktrCond) {dput(hidden_dentry); hidden_dentry = ERR_PTR(-1);}
408
err = PTR_ERR(hidden_dentry);
409
if (IS_ERR(hidden_dentry))
411
if (unlikely(hidden_dentry->d_inode)) {
413
IOErr("b%d %.*s should be negative.%s\n",
414
bindex, DLNPair(hidden_dentry),
415
au_flag_test(dentry->d_sb, AuFlag_UDBA_INOTIFY) ? "" :
416
" Try udba=inotify.");
421
if (bindex < dbstart(dentry))
422
set_dbstart(dentry, bindex);
423
if (dbend(dentry) < bindex)
424
set_dbend(dentry, bindex);
425
set_h_dptr(dentry, bindex, hidden_dentry);
435
* returns the number of found hidden positive dentries,
436
* otherwise an error.
438
int au_refresh_hdentry(struct dentry *dentry, mode_t type)
440
int npositive, pgen, new_sz, sgen, dgen;
441
struct aufs_dinfo *dinfo;
442
struct super_block *sb;
443
struct dentry *parent;
444
aufs_bindex_t bindex, parent_bend, parent_bstart, bwh, bdiropq, bend;
445
struct aufs_hdentry *p;
446
//struct nameidata nd;
448
LKTRTrace("%.*s, type 0%o\n", DLNPair(dentry), type);
449
DiMustWriteLock(dentry);
451
DEBUG_ON(IS_ROOT(dentry));
452
parent = dget_parent(dentry);
453
pgen = au_digen(parent);
455
dgen = au_digen(dentry);
456
DEBUG_ON(pgen != sgen
457
|| AufsGenOlder(sgen, dgen)
458
|| AufsGenOlder(pgen, dgen));
461
new_sz = sizeof(*dinfo->di_hdentry) * (sbend(sb) + 1);
462
dinfo = dtodi(dentry);
463
p = au_kzrealloc(dinfo->di_hdentry, sizeof(*p) * (dinfo->di_bend + 1),
468
dinfo->di_hdentry = p;
470
bend = dinfo->di_bend;
472
bdiropq = dinfo->di_bdiropq;
473
p += dinfo->di_bstart;
474
for (bindex = dinfo->di_bstart; bindex <= bend; bindex++, p++) {
475
struct dentry *hd, *hdp;
476
struct aufs_hdentry tmp, *q;
477
aufs_bindex_t new_bindex;
482
hdp = dget_parent(hd);
483
if (hdp == au_h_dptr_i(parent, bindex)) {
488
new_bindex = au_find_dbindex(parent, hdp);
490
DEBUG_ON(new_bindex == bindex);
491
if (dinfo->di_bwh == bindex)
493
if (dinfo->di_bdiropq == bindex)
494
bdiropq = new_bindex;
495
if (new_bindex < 0) { // test here
500
/* swap two hidden dentries, and loop again */
501
q = dinfo->di_hdentry + new_bindex;
513
if (unlikely(bwh != -1 && bwh <= sbend(sb) && sbr_is_whable(sb, bwh)))
515
dinfo->di_bdiropq = -1;
516
if (unlikely(bdiropq != -1 && bdiropq <= sbend(sb)
517
&& sbr_is_whable(sb, bdiropq)))
518
dinfo->di_bdiropq = bdiropq;
519
parent_bend = dbend(parent);
520
p = dinfo->di_hdentry;
521
for (bindex = 0; bindex <= parent_bend; bindex++, p++)
523
dinfo->di_bstart = bindex;
526
p = dinfo->di_hdentry + parent_bend;
527
//for (bindex = parent_bend; bindex > dinfo->di_bstart; bindex--, p--)
528
for (bindex = parent_bend; bindex >= 0; bindex--, p--)
530
dinfo->di_bend = bindex;
535
parent_bstart = dbstart(parent);
536
if (type != S_IFDIR && dinfo->di_bstart == parent_bstart)
537
goto out_dgen; /* success */
540
nd.last_type = LAST_ROOT;
541
nd.flags = LOOKUP_FOLLOW;
544
nd.dentry = dget(parent);
546
npositive = lkup_dentry(dentry, parent_bstart, type);
547
//if (LktrCond) npositive = -1;
552
au_update_digen(dentry);
559
static int h_d_revalidate(struct dentry *dentry, struct nameidata *nd,
562
int err, plus, locked, unhashed, is_root, h_plus, is_nfs;
563
struct nameidata fake_nd, *p;
564
aufs_bindex_t bindex, btail, bstart, ibs, ibe;
565
struct super_block *sb;
566
struct inode *inode, *first, *h_inode, *h_cached_inode;
567
umode_t mode, h_mode;
568
struct dentry *h_dentry;
569
int (*reval)(struct dentry *, struct nameidata *);
572
LKTRTrace("%.*s\n", DLNPair(dentry));
573
inode = dentry->d_inode;
574
DEBUG_ON(inode && au_digen(dentry) != au_iigen(inode));
584
unhashed = d_unhashed(dentry);
585
is_root = IS_ROOT(dentry);
586
name = &dentry->d_name;
589
* Theoretically, REVAL test should be unnecessary in case of INOTIFY.
590
* But inotify doesn't fire some necessary events,
591
* IN_ATTRIB for atime/nlink/pageio
592
* IN_DELETE for NFS dentry
593
* Let's do REVAL test too.
595
if (do_udba && inode) {
596
mode = (inode->i_mode & S_IFMT);
597
plus = (inode->i_nlink > 0);
598
first = au_h_iptr(inode);
599
ibs = ibstart(inode);
603
btail = bstart = dbstart(dentry);
604
if (inode && S_ISDIR(inode->i_mode))
605
btail = dbtaildir(dentry);
609
#ifndef CONFIG_AUFS_FAKE_DM
610
if (dentry != nd->dentry) {
611
di_read_lock_parent(nd->dentry, 0);
616
for (bindex = bstart; bindex <= btail; bindex++) {
617
h_dentry = au_h_dptr_i(dentry, bindex);
618
if (unlikely(!h_dentry))
622
&& (unhashed != d_unhashed(h_dentry)
624
|| name->len != h_dentry->d_name.len
625
|| memcmp(name->name, h_dentry->d_name.name,
629
LKTRTrace("unhash 0x%x 0x%x, %.*s %.*s\n",
630
unhashed, d_unhashed(h_dentry),
631
DLNPair(dentry), DLNPair(h_dentry));
637
reval = h_dentry->d_op->d_revalidate;
638
if (unlikely(reval)) {
639
//LKTRLabel(hidden reval);
640
p = fake_dm(&fake_nd, nd, sb, bindex);
642
err = !reval(h_dentry, p);
650
if (unlikely(!do_udba))
654
h_inode = h_dentry->d_inode;
655
if (unlikely(!!inode != !!h_inode)) {
662
h_cached_inode = h_inode;
665
h_mode = (h_inode->i_mode & S_IFMT);
666
h_plus = (h_inode->i_nlink > 0);
668
if (inode && ibs <= bindex && bindex <= ibe) {
669
h_cached_inode = au_h_iptr_i(inode, bindex);
670
//is_nfs = au_is_nfs(h_cached_inode->i_sb);
673
LKTRTrace("{%d, 0%o, %p}, h{%d, 0%o, %p}\n",
674
plus, mode, h_cached_inode,
675
h_plus, h_mode, h_inode);
676
if (unlikely(plus != h_plus || mode != h_mode
677
|| (h_cached_inode != h_inode /* && !is_nfs */))) {
687
#ifndef CONFIG_AUFS_FAKE_DM
688
if (unlikely(locked))
689
di_read_unlock(nd->dentry, 0);
693
// some filesystem uses CURRENT_TIME_SEC instead of CURRENT_TIME.
694
// NFS may stop IN_DELETE because of DCACHE_NFSFS_RENAMED.
696
&& (!timespec_equal(&inode->i_ctime, &first->i_ctime)
697
|| !timespec_equal(&inode->i_atime, &first->i_atime))
699
if (unlikely(!err && udba && first))
700
au_cpup_attr_all(inode);
707
static int simple_reval_dpath(struct dentry *dentry, int sgen)
711
struct dentry *parent;
714
LKTRTrace("%.*s, sgen %d\n", DLNPair(dentry), sgen);
715
SiMustAnyLock(dentry->d_sb);
716
DiMustWriteLock(dentry);
717
inode = dentry->d_inode;
720
if (!AufsGenOlder(au_digen(dentry), sgen))
723
parent = dget_parent(dentry);
724
di_read_lock_parent(parent, AUFS_I_RLOCK);
725
DEBUG_ON(au_digen(parent) != sgen);
726
#ifdef CONFIG_AUFS_DEBUG
728
struct dentry *d = parent;
729
while (!IS_ROOT(d)) {
730
DEBUG_ON(au_digen(d) != sgen);
735
type = (inode->i_mode & S_IFMT);
736
/* returns a number of positive dentries */
737
err = au_refresh_hdentry(dentry, type);
739
err = au_refresh_hinode(inode, dentry);
740
di_read_unlock(parent, AUFS_I_RLOCK);
746
int au_reval_dpath(struct dentry *dentry, int sgen)
749
struct dentry *d, *parent;
752
LKTRTrace("%.*s, sgen %d\n", DLNPair(dentry), sgen);
753
DEBUG_ON(!dentry->d_inode);
754
DiMustWriteLock(dentry);
756
if (!stosi(dentry->d_sb)->si_failed_refresh_dirs)
757
return simple_reval_dpath(dentry, sgen);
759
/* slow loop, keep it simple and stupid */
760
/* cf: cpup_dirs() */
762
while (au_digen(dentry) != sgen) {
765
parent = d->d_parent; // dget_parent()
766
if (au_digen(parent) == sgen)
774
di_write_lock_child(d);
777
/* someone might update our dentry while we were sleeping */
778
if (AufsGenOlder(au_digen(d), sgen)) {
779
di_read_lock_parent(parent, AUFS_I_RLOCK);
780
/* returns a number of positive dentries */
781
err = au_refresh_hdentry(d, inode->i_mode & S_IFMT);
784
err = au_refresh_hinode(inode, d);
786
di_read_unlock(parent, AUFS_I_RLOCK);
802
* THIS IS A BOOLEAN FUNCTION: returns 1 if valid, 0 otherwise.
803
* nfsd passes NULL as nameidata.
805
static int aufs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
807
int valid, sgen, err, do_udba;
808
struct super_block *sb;
811
LKTRTrace("dentry %.*s\n", DLNPair(dentry));
812
if (nd && nd->dentry)
813
LKTRTrace("nd %.*s\n", DLNPair(nd->dentry));
814
//dir case: DEBUG_ON(dentry->d_parent != nd->dentry);
815
//remove failure case: DEBUG_ON(!IS_ROOT(dentry) && d_unhashed(dentry));
816
DEBUG_ON(!dentry->d_fsdata);
820
inode = dentry->d_inode;
825
if (au_digen(dentry) == sgen)
826
di_read_lock_child(dentry, !AUFS_I_RLOCK);
828
DEBUG_ON(IS_ROOT(dentry));
830
Dbg("UDBA or digen, %.*s\n", DLNPair(dentry));
833
di_write_lock_child(dentry);
835
err = au_reval_dpath(dentry, sgen);
837
di_downgrade_lock(dentry, AUFS_I_RLOCK);
841
ii_read_unlock(inode);
842
DEBUG_ON(au_iigen(inode) != sgen);
846
if (au_iigen(inode) == sgen)
847
ii_read_lock_child(inode);
849
DEBUG_ON(IS_ROOT(dentry));
851
Dbg("UDBA or survived, %.*s\n", DLNPair(dentry));
853
ii_write_lock_child(inode);
854
err = au_refresh_hinode(inode, dentry);
855
ii_downgrade_lock(inode);
858
DEBUG_ON(au_iigen(inode) != sgen);
863
/* parent dir i_nlink is not updated in the case of setattr */
864
if (S_ISDIR(inode->i_mode)) {
866
ii_write_lock(inode);
867
au_cpup_attr_nlink(inode);
868
ii_write_unlock(inode);
874
do_udba = !au_flag_test(sb, AuFlag_UDBA_NONE);
875
if (do_udba && inode && ibstart(inode) >= 0
876
&& au_test_higen(inode, au_h_iptr(inode)))
878
err = h_d_revalidate(dentry, nd, do_udba);
882
aufs_read_unlock(dentry, AUFS_I_RLOCK);
887
LKTRTrace("%.*s invalid\n", DLNPair(dentry));
892
static void aufs_d_release(struct dentry *dentry)
894
struct aufs_dinfo *dinfo;
895
aufs_bindex_t bend, bindex;
897
LKTRTrace("%.*s\n", DLNPair(dentry));
898
DEBUG_ON(!d_unhashed(dentry));
900
dinfo = dentry->d_fsdata;
901
if (unlikely(!dinfo))
904
/* dentry may not be revalidated */
905
bindex = dinfo->di_bstart;
907
struct aufs_hdentry *p;
908
bend = dinfo->di_bend;
909
DEBUG_ON(bend < bindex);
910
p = dinfo->di_hdentry + bindex;
911
while (bindex++ <= bend) {
917
kfree(dinfo->di_hdentry);
918
cache_free_dinfo(dinfo);
922
/* it may be called at remount time, too */
923
static void aufs_d_iput(struct dentry *dentry, struct inode *inode)
925
struct super_block *sb;
927
LKTRTrace("%.*s, i%lu\n", DLNPair(dentry), inode->i_ino);
932
if (unlikely(au_flag_test(sb, AuFlag_PLINK)
933
&& au_is_plinked(sb, inode))) {
934
ii_write_lock(inode);
935
au_update_brange(inode, 1);
936
ii_write_unlock(inode);
944
struct dentry_operations aufs_dop = {
945
.d_revalidate = aufs_d_revalidate,
946
.d_release = aufs_d_release
947
//.d_iput = aufs_d_iput